(to_wc): Mark as const. (to_mb): Likewise.
[glibc.git] / elf / tst-tls3.c
blob84be43575b6c59f81f74e357d7b56223e07d4c45
1 /* glibc test for TLS in ld.so. */
2 #include <stdio.h>
4 #include <tls.h>
6 #ifdef USE_TLS
7 # include "tls-macros.h"
10 /* One define int variable, two externs. */
11 COMMON_INT_DECL(foo);
12 VAR_INT_DECL(bar);
13 VAR_INT_DEF(baz);
14 #endif
17 extern int in_dso (void);
20 #define TEST_FUNCTION do_test ()
21 static int
22 do_test (void)
24 #ifdef USE_TLS
25 int result = 0;
26 int *ap, *bp, *cp;
29 /* Set the variable using the local exec model. */
30 puts ("set baz to 3 (LE)");
31 ap = TLS_LE (baz);
32 *ap = 3;
35 /* Get variables using initial exec model. */
36 puts ("set variables foo and bar (IE)");
37 ap = TLS_IE (foo);
38 *ap = 1;
39 bp = TLS_IE (bar);
40 *bp = 2;
43 /* Get variables using local dynamic model. */
44 fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
45 ap = TLS_GD (foo);
46 bp = TLS_GD (bar);
47 cp = TLS_LD (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;
67 result |= in_dso ();
69 return result;
70 #else
71 return 0;
72 #endif
76 #include "../test-skeleton.c"