Update.
[glibc.git] / elf / tst-tlsmod1.c
blob946aa375cccc999e9f6784ddd88d2c66be79e361
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
15 extern int in_dso (void);
17 int
18 in_dso (void)
20 int result = 0;
21 #ifdef USE_TLS
22 int *ap, *bp, *cp;
24 /* Get variables using initial exec model. */
25 fputs ("get sum of foo and bar (IE)", stdout);
26 ap = TLS_IE (foo);
27 bp = TLS_IE (bar);
28 printf (" = %d\n", *ap + *bp);
29 result |= *ap + *bp != 3;
30 if (*ap != 1)
32 printf ("foo = %d\n", *ap);
33 result = 1;
35 if (*bp != 2)
37 printf ("bar = %d\n", *bp);
38 result = 1;
42 /* Get variables using generic dynamic model. */
43 fputs ("get sum of foo and bar and baz (GD)", stdout);
44 ap = TLS_GD (foo);
45 bp = TLS_GD (bar);
46 cp = TLS_GD (baz);
47 printf (" = %d\n", *ap + *bp + *cp);
48 result |= *ap + *bp + *cp != 6;
49 if (*ap != 1)
51 printf ("foo = %d\n", *ap);
52 result = 1;
54 if (*bp != 2)
56 printf ("bar = %d\n", *bp);
57 result = 1;
59 if (*cp != 3)
61 printf ("baz = %d\n", *cp);
62 result = 1;
64 #endif
66 return result;