Fix last change
[glibc.git] / elf / tst-tls2.c
blob3d13272c08a0c1426fef68f02c273afb70cfd832
1 /* glibc test for TLS in ld.so. */
2 #include <stdio.h>
4 #include <tls.h>
6 #include "tls-macros.h"
9 /* Two 'int' variables in TLS. */
10 VAR_INT_DEF(foo);
11 VAR_INT_DEF(bar);
14 #define TEST_FUNCTION do_test ()
15 static int
16 do_test (void)
18 int result = 0;
19 int *ap, *bp;
22 /* Set the variable using the local exec model. */
23 puts ("set bar to 1 (LE)");
24 ap = TLS_LE (bar);
25 *ap = 1;
28 /* Get variables using initial exec model. */
29 fputs ("get sum of foo and bar (IE)", stdout);
30 ap = TLS_IE (foo);
31 bp = TLS_IE (bar);
32 printf (" = %d\n", *ap + *bp);
33 result |= *ap + *bp != 1;
34 if (*ap != 0)
36 printf ("foo = %d\n", *ap);
37 result = 1;
39 if (*bp != 1)
41 printf ("bar = %d\n", *bp);
42 result = 1;
46 /* Get variables using local dynamic model. */
47 fputs ("get sum of foo and bar (LD)", stdout);
48 ap = TLS_LD (foo);
49 bp = TLS_LD (bar);
50 printf (" = %d\n", *ap + *bp);
51 result |= *ap + *bp != 1;
52 if (*ap != 0)
54 printf ("foo = %d\n", *ap);
55 result = 1;
57 if (*bp != 1)
59 printf ("bar = %d\n", *bp);
60 result = 1;
64 /* Get variables using generic dynamic model. */
65 fputs ("get sum of foo and bar (GD)", stdout);
66 ap = TLS_GD (foo);
67 bp = TLS_GD (bar);
68 printf (" = %d\n", *ap + *bp);
69 result |= *ap + *bp != 1;
70 if (*ap != 0)
72 printf ("foo = %d\n", *ap);
73 result = 1;
75 if (*bp != 1)
77 printf ("bar = %d\n", *bp);
78 result = 1;
81 return result;
85 #include "../test-skeleton.c"