ubacktrace/uargp: remove unneeded and false linker scripts
[uclibc-ng.git] / test / tls / tst-tls1.c
blobf5ac6d2bcba704a2045e7ab5fe8c1d74639658bd
1 /* glibc test for TLS in ld.so. */
2 #undef _LIBC
3 #include <stdio.h>
5 #include <tls.h>
7 #ifdef USE_TLS
8 # include "tls-macros.h"
11 /* Two common 'int' variables in TLS. */
12 COMMON_INT_DEF(foo);
13 COMMON_INT_DEF(bar);
14 #endif
17 #define TEST_FUNCTION do_test ()
18 static int
19 do_test (void)
21 #ifdef USE_TLS
22 int result = 0;
23 int *ap, *bp;
26 /* Set the variable using the local exec model. */
27 puts ("set bar to 1 (LE)");
28 ap = TLS_LE (bar);
29 *ap = 1;
32 /* Get variables using initial exec model. */
33 fputs ("get sum of foo and bar (IE)", stdout);
34 ap = TLS_IE (foo);
35 bp = TLS_IE (bar);
36 printf (" = %d\n", *ap + *bp);
37 result |= *ap + *bp != 1;
38 if (*ap != 0)
40 printf ("foo = %d\n", *ap);
41 result = 1;
43 if (*bp != 1)
45 printf ("bar = %d\n", *bp);
46 result = 1;
50 /* Get variables using local dynamic model. */
51 fputs ("get sum of foo and bar (LD)", stdout);
52 ap = TLS_LD (foo);
53 bp = TLS_LD (bar);
54 printf (" = %d\n", *ap + *bp);
55 result |= *ap + *bp != 1;
56 if (*ap != 0)
58 printf ("foo = %d\n", *ap);
59 result = 1;
61 if (*bp != 1)
63 printf ("bar = %d\n", *bp);
64 result = 1;
68 /* Get variables using generic dynamic model. */
69 fputs ("get sum of foo and bar (GD)", stdout);
70 ap = TLS_GD (foo);
71 bp = TLS_GD (bar);
72 printf (" = %d\n", *ap + *bp);
73 result |= *ap + *bp != 1;
74 if (*ap != 0)
76 printf ("foo = %d\n", *ap);
77 result = 1;
79 if (*bp != 1)
81 printf ("bar = %d\n", *bp);
82 result = 1;
85 return result;
86 #else
87 return 0;
88 #endif
92 #include "../test-skeleton.c"