Mention IFUNC enhancements to testsuite in NEWS.
[platform/upstream/glibc.git] / elf / tst-tlsmod1.c
1 #include <stdio.h>
2
3 #include <tls.h>
4
5 #include "tls-macros.h"
6
7
8 /* One define int variable, two externs.  */
9 COMMON_INT_DEF(foo);
10 VAR_INT_DEF(bar);
11 VAR_INT_DECL(baz);
12
13 extern int in_dso (void);
14
15 int
16 in_dso (void)
17 {
18   int result = 0;
19   int *ap, *bp, *cp;
20
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)
29     {
30       printf ("foo = %d\n", *ap);
31       result = 1;
32     }
33   if (*bp != 2)
34     {
35       printf ("bar = %d\n", *bp);
36       result = 1;
37     }
38
39
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)
48     {
49       printf ("foo = %d\n", *ap);
50       result = 1;
51     }
52   if (*bp != 2)
53     {
54       printf ("bar = %d\n", *bp);
55       result = 1;
56     }
57   if (*cp != 3)
58     {
59       printf ("baz = %d\n", *cp);
60       result = 1;
61     }
62
63   return result;
64 }