2004-07-01 Roland McGrath <roland@redhat.com>
[glibc.git] / elf / tst-tlsmod1.c
blobc74a617b77a3bc7e3705162b8794fabff6140129
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 asm ("" ::: "memory");
27 ap = TLS_IE (foo);
28 bp = TLS_IE (bar);
29 printf (" = %d\n", *ap + *bp);
30 result |= *ap + *bp != 3;
31 if (*ap != 1)
33 printf ("foo = %d\n", *ap);
34 result = 1;
36 if (*bp != 2)
38 printf ("bar = %d\n", *bp);
39 result = 1;
43 /* Get variables using generic dynamic model. */
44 fputs ("get sum of foo and bar and baz (GD)", stdout);
45 ap = TLS_GD (foo);
46 bp = TLS_GD (bar);
47 cp = TLS_GD (baz);
48 printf (" = %d\n", *ap + *bp + *cp);
49 result |= *ap + *bp + *cp != 6;
50 if (*ap != 1)
52 printf ("foo = %d\n", *ap);
53 result = 1;
55 if (*bp != 2)
57 printf ("bar = %d\n", *bp);
58 result = 1;
60 if (*cp != 3)
62 printf ("baz = %d\n", *cp);
63 result = 1;
65 #endif
67 return result;