Update.
[glibc.git] / elf / tst-tlsmod1.c
blob7e768a6593bef153ac29439aee1df1de0a0ca7c4
1 #include <stdio.h>
3 #include <tls.h>
5 #ifdef USE_TLS
6 #include "tls-macros.h"
9 /* One define int variable, two externs. */
10 COMMON_INT_DEF(foo);
11 VAR_INT_DEF(bar);
12 VAR_INT_DECL(baz);
13 #endif
16 int
17 in_dso (void)
19 int result = 0;
20 #ifdef USE_TLS
21 int *ap, *bp, *cp;
23 /* Get variables using initial exec model. */
24 fputs ("get sum of foo and bar (IE)", stdout);
25 ap = TLS_IE (foo);
26 bp = TLS_IE (bar);
27 printf (" = %d\n", *ap + *bp);
28 result |= *ap + *bp != 3;
29 if (*ap != 1)
31 printf ("foo = %d\n", *ap);
32 result = 1;
34 if (*bp != 2)
36 printf ("bar = %d\n", *bp);
37 result = 1;
41 /* Get variables using generic dynamic model. */
42 fputs ("get sum of foo and bar and baz (GD)", stdout);
43 ap = TLS_GD (foo);
44 bp = TLS_GD (bar);
45 cp = TLS_GD (baz);
46 printf (" = %d\n", *ap + *bp + *cp);
47 result |= *ap + *bp + *cp != 6;
48 if (*ap != 1)
50 printf ("foo = %d\n", *ap);
51 result = 1;
53 if (*bp != 2)
55 printf ("bar = %d\n", *bp);
56 result = 1;
58 if (*cp != 3)
60 printf ("baz = %d\n", *cp);
61 result = 1;
63 #endif
65 return result;