Include <kernel-features.h>.
[glibc/history.git] / elf / tst-tlsmod1.c
blob4d966c9472ca3cc471ada8557697837702ebc305
1 #include <stdio.h>
3 #include <tls.h>
5 #include "tls-macros.h"
8 /* One define int variable, two externs. */
9 COMMON_INT_DEF(foo);
10 VAR_INT_DEF(bar);
11 VAR_INT_DECL(baz);
13 extern int in_dso (void);
15 int
16 in_dso (void)
18 int result = 0;
19 int *ap, *bp, *cp;
21 /* Get variables using initial exec model. */
22 fputs ("get sum of foo and bar (IE)", stdout);
23 asm ("" ::: "memory");
24 ap = TLS_IE (foo);
25 bp = TLS_IE (bar);
26 printf (" = %d\n", *ap + *bp);
27 result |= *ap + *bp != 3;
28 if (*ap != 1)
30 printf ("foo = %d\n", *ap);
31 result = 1;
33 if (*bp != 2)
35 printf ("bar = %d\n", *bp);
36 result = 1;
40 /* Get variables using generic dynamic model. */
41 fputs ("get sum of foo and bar and baz (GD)", stdout);
42 ap = TLS_GD (foo);
43 bp = TLS_GD (bar);
44 cp = TLS_GD (baz);
45 printf (" = %d\n", *ap + *bp + *cp);
46 result |= *ap + *bp + *cp != 6;
47 if (*ap != 1)
49 printf ("foo = %d\n", *ap);
50 result = 1;
52 if (*bp != 2)
54 printf ("bar = %d\n", *bp);
55 result = 1;
57 if (*cp != 3)
59 printf ("baz = %d\n", *cp);
60 result = 1;
63 return result;