chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / elf / tst-tls3.c
1 /* glibc test for TLS in ld.so.  */
2 #include <stdio.h>
3
4 #include <tls.h>
5
6 #include "tls-macros.h"
7
8
9 /* One define int variable, two externs.  */
10 COMMON_INT_DECL(foo);
11 VAR_INT_DECL(bar);
12 VAR_INT_DEF(baz);
13
14
15 extern int in_dso (void);
16
17
18 #define TEST_FUNCTION do_test ()
19 static int
20 do_test (void)
21 {
22   int result = 0;
23   int *ap, *bp, *cp;
24
25
26   /* Set the variable using the local exec model.  */
27   puts ("set baz to 3 (LE)");
28   ap = TLS_LE (baz);
29   *ap = 3;
30
31
32   /* Get variables using initial exec model.  */
33   puts ("set variables foo and bar (IE)");
34   ap = TLS_IE (foo);
35   *ap = 1;
36   bp = TLS_IE (bar);
37   *bp = 2;
38
39
40   /* Get variables using local dynamic model.  */
41   fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
42   ap = TLS_GD (foo);
43   bp = TLS_GD (bar);
44   cp = TLS_LD (baz);
45   printf (" = %d\n", *ap + *bp + *cp);
46   result |= *ap + *bp + *cp != 6;
47   if (*ap != 1)
48     {
49       printf ("foo = %d\n", *ap);
50       result = 1;
51     }
52   if (*bp != 2)
53     {
54       printf ("bar = %d\n", *bp);
55       result = 1;
56     }
57   if (*cp != 3)
58     {
59       printf ("baz = %d\n", *cp);
60       result = 1;
61     }
62
63
64   result |= in_dso ();
65
66   return result;
67 }
68
69
70 #include "../test-skeleton.c"