]>
Commit | Line | Data |
---|---|---|
2e36cb48 UD |
1 | #include <stdio.h> |
2 | ||
2e36cb48 | 3 | |
33c50ef4 FS |
4 | __thread int foo, bar __attribute__ ((tls_model("global-dynamic"))); |
5 | extern __thread int baz __attribute__ ((tls_model("global-dynamic"))); | |
6 | extern __thread int foo_ie asm ("foo") __attribute__ ((tls_model("initial-exec"))); | |
7 | extern __thread int bar_ie asm ("bar") __attribute__ ((tls_model("initial-exec"))); | |
8 | extern __thread int baz_ie asm ("baz") __attribute__ ((tls_model("initial-exec"))); | |
2e36cb48 | 9 | |
2e36cb48 | 10 | |
37de950b | 11 | extern int in_dso (void); |
2e36cb48 UD |
12 | |
13 | int | |
14 | in_dso (void) | |
15 | { | |
16 | int result = 0; | |
2e36cb48 UD |
17 | int *ap, *bp, *cp; |
18 | ||
19 | /* Get variables using initial exec model. */ | |
20 | fputs ("get sum of foo and bar (IE)", stdout); | |
046b4069 | 21 | asm ("" ::: "memory"); |
33c50ef4 FS |
22 | ap = &foo_ie; |
23 | bp = &bar_ie; | |
2e36cb48 UD |
24 | printf (" = %d\n", *ap + *bp); |
25 | result |= *ap + *bp != 3; | |
26 | if (*ap != 1) | |
27 | { | |
28 | printf ("foo = %d\n", *ap); | |
29 | result = 1; | |
30 | } | |
31 | if (*bp != 2) | |
32 | { | |
33 | printf ("bar = %d\n", *bp); | |
34 | result = 1; | |
35 | } | |
36 | ||
37 | ||
33c50ef4 FS |
38 | /* Get variables using generic dynamic model or TLSDESC. */ |
39 | fputs ("get sum of foo and bar and baz (GD or TLSDESC)", stdout); | |
40 | ap = &foo; | |
41 | bp = &bar; | |
42 | cp = &baz; | |
2e36cb48 UD |
43 | printf (" = %d\n", *ap + *bp + *cp); |
44 | result |= *ap + *bp + *cp != 6; | |
45 | if (*ap != 1) | |
46 | { | |
47 | printf ("foo = %d\n", *ap); | |
48 | result = 1; | |
49 | } | |
50 | if (*bp != 2) | |
51 | { | |
52 | printf ("bar = %d\n", *bp); | |
53 | result = 1; | |
54 | } | |
55 | if (*cp != 3) | |
56 | { | |
57 | printf ("baz = %d\n", *cp); | |
58 | result = 1; | |
59 | } | |
2e36cb48 UD |
60 | |
61 | return result; | |
62 | } |