]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/tst-tls3.c
(RESOLVE_MAP): Return NULL not 0.
[thirdparty/glibc.git] / elf / tst-tls3.c
CommitLineData
2e36cb48
UD
1/* glibc test for TLS in ld.so. */
2#include <stdio.h>
3
4#include <tls.h>
5#include "tls-macros.h"
6
7
8/* One define int variable, two externs. */
9COMMON_INT_DECL(foo);
10VAR_INT_DECL(bar);
11VAR_INT_DEF(baz);
12
13
14extern int in_dso (void);
15
16
17int
18main (void)
19{
20#ifdef USE_TLS
21 int result = 0;
22 int *ap, *bp, *cp;
23
24
25 /* Set the variable using the local exec model. */
26 puts ("set baz to 3 (LE)");
27 ap = TLS_LE (baz);
28 *ap = 3;
29
30
31 /* Get variables using initial exec model. */
32 puts ("set variables foo and bar (IE)");
33 ap = TLS_IE (foo);
34 *ap = 1;
35 bp = TLS_IE (bar);
36 *bp = 2;
37
38
39 /* Get variables using local dynamic model. */
40 fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
41 ap = TLS_GD (foo);
42 bp = TLS_GD (bar);
43 cp = TLS_LD (baz);
44 printf (" = %d\n", *ap + *bp + *cp);
45 result |= *ap + *bp + *cp != 6;
46 if (*ap != 1)
47 {
48 printf ("foo = %d\n", *ap);
49 result = 1;
50 }
51 if (*bp != 2)
52 {
53 printf ("bar = %d\n", *bp);
54 result = 1;
55 }
56 if (*cp != 3)
57 {
58 printf ("baz = %d\n", *cp);
59 result = 1;
60 }
61
62
63 result |= in_dso ();
64
65 return result;
66#else
67 return 0;
68#endif
69}