]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/tst-tls3.c
test-container: Fix "unused code" warnings on HURD
[thirdparty/glibc.git] / elf / tst-tls3.c
CommitLineData
2e36cb48
UD
1/* glibc test for TLS in ld.so. */
2#include <stdio.h>
3
100e184f 4
33c50ef4
FS
5__thread int foo, bar __attribute__ ((tls_model("initial-exec")));
6__thread int baz __attribute__ ((tls_model("local-exec")));
7extern __thread int foo_gd __attribute__ ((alias("foo"), tls_model("global-dynamic")));
8extern __thread int bar_gd __attribute__ ((alias("bar"), tls_model("global-dynamic")));
9extern __thread int baz_ld __attribute__ ((alias("baz"), tls_model("local-dynamic")));
2e36cb48
UD
10
11
12extern int in_dso (void);
13
14
aed283dd
UD
15static int
16do_test (void)
2e36cb48 17{
2e36cb48
UD
18 int result = 0;
19 int *ap, *bp, *cp;
20
21
22 /* Set the variable using the local exec model. */
23 puts ("set baz to 3 (LE)");
33c50ef4 24 baz = 3;
2e36cb48
UD
25
26
27 /* Get variables using initial exec model. */
28 puts ("set variables foo and bar (IE)");
33c50ef4
FS
29 foo = 1;
30 bar = 2;
2e36cb48
UD
31
32
33 /* Get variables using local dynamic model. */
34 fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
33c50ef4
FS
35 ap = &foo_gd;
36 bp = &bar_gd;
37 cp = &baz_ld;
2e36cb48
UD
38 printf (" = %d\n", *ap + *bp + *cp);
39 result |= *ap + *bp + *cp != 6;
40 if (*ap != 1)
41 {
42 printf ("foo = %d\n", *ap);
43 result = 1;
44 }
45 if (*bp != 2)
46 {
47 printf ("bar = %d\n", *bp);
48 result = 1;
49 }
50 if (*cp != 3)
51 {
52 printf ("baz = %d\n", *cp);
53 result = 1;
54 }
55
56
57 result |= in_dso ();
58
59 return result;
2e36cb48 60}
aed283dd
UD
61
62
36fe25fd 63#include <support/test-driver.c>