ld.so: Add architecture specific fields
[glibc.git] / elf / tst-tls1.c
blobc31da56ce9cb3e8ffcbfc65489914d700debdec2
1 /* glibc test for TLS in ld.so. */
2 #include <stdio.h>
4 #include "tls-macros.h"
7 /* Two common 'int' variables in TLS. */
8 COMMON_INT_DEF(foo);
9 COMMON_INT_DEF(bar);
12 static int
13 do_test (void)
15 int result = 0;
16 int *ap, *bp;
19 /* Set the variable using the local exec model. */
20 puts ("set bar to 1 (LE)");
21 ap = TLS_LE (bar);
22 *ap = 1;
25 /* Get variables using initial exec model. */
26 fputs ("get sum of foo and bar (IE)", stdout);
27 ap = TLS_IE (foo);
28 bp = TLS_IE (bar);
29 printf (" = %d\n", *ap + *bp);
30 result |= *ap + *bp != 1;
31 if (*ap != 0)
33 printf ("foo = %d\n", *ap);
34 result = 1;
36 if (*bp != 1)
38 printf ("bar = %d\n", *bp);
39 result = 1;
43 /* Get variables using local dynamic model. */
44 fputs ("get sum of foo and bar (LD)", stdout);
45 ap = TLS_LD (foo);
46 bp = TLS_LD (bar);
47 printf (" = %d\n", *ap + *bp);
48 result |= *ap + *bp != 1;
49 if (*ap != 0)
51 printf ("foo = %d\n", *ap);
52 result = 1;
54 if (*bp != 1)
56 printf ("bar = %d\n", *bp);
57 result = 1;
61 /* Get variables using generic dynamic model. */
62 fputs ("get sum of foo and bar (GD)", stdout);
63 ap = TLS_GD (foo);
64 bp = TLS_GD (bar);
65 printf (" = %d\n", *ap + *bp);
66 result |= *ap + *bp != 1;
67 if (*ap != 0)
69 printf ("foo = %d\n", *ap);
70 result = 1;
72 if (*bp != 1)
74 printf ("bar = %d\n", *bp);
75 result = 1;
78 return result;
82 #include <support/test-driver.c>