]>
Commit | Line | Data |
---|---|---|
2cef4257 UD |
1 | /* glibc test for TLS in ld.so. */ |
2 | #include <stdio.h> | |
3 | ||
11bf311e | 4 | #include "tls-macros.h" |
100e184f UD |
5 | |
6 | ||
2cef4257 UD |
7 | /* Two 'int' variables in TLS. */ |
8 | VAR_INT_DEF(foo); | |
9 | VAR_INT_DEF(bar); | |
10 | ||
11 | ||
aed283dd UD |
12 | #define TEST_FUNCTION do_test () |
13 | static int | |
14 | do_test (void) | |
2cef4257 | 15 | { |
2cef4257 UD |
16 | int result = 0; |
17 | int *ap, *bp; | |
18 | ||
19 | ||
20 | /* Set the variable using the local exec model. */ | |
21 | puts ("set bar to 1 (LE)"); | |
22 | ap = TLS_LE (bar); | |
23 | *ap = 1; | |
24 | ||
25 | ||
26 | /* Get variables using initial exec model. */ | |
27 | fputs ("get sum of foo and bar (IE)", stdout); | |
28 | ap = TLS_IE (foo); | |
29 | bp = TLS_IE (bar); | |
30 | printf (" = %d\n", *ap + *bp); | |
31 | result |= *ap + *bp != 1; | |
32 | if (*ap != 0) | |
33 | { | |
34 | printf ("foo = %d\n", *ap); | |
35 | result = 1; | |
36 | } | |
37 | if (*bp != 1) | |
38 | { | |
39 | printf ("bar = %d\n", *bp); | |
40 | result = 1; | |
41 | } | |
42 | ||
43 | ||
44 | /* Get variables using local dynamic model. */ | |
45 | fputs ("get sum of foo and bar (LD)", stdout); | |
46 | ap = TLS_LD (foo); | |
47 | bp = TLS_LD (bar); | |
48 | printf (" = %d\n", *ap + *bp); | |
49 | result |= *ap + *bp != 1; | |
50 | if (*ap != 0) | |
51 | { | |
52 | printf ("foo = %d\n", *ap); | |
53 | result = 1; | |
54 | } | |
55 | if (*bp != 1) | |
56 | { | |
57 | printf ("bar = %d\n", *bp); | |
58 | result = 1; | |
59 | } | |
60 | ||
61 | ||
62 | /* Get variables using generic dynamic model. */ | |
63 | fputs ("get sum of foo and bar (GD)", stdout); | |
64 | ap = TLS_GD (foo); | |
65 | bp = TLS_GD (bar); | |
66 | printf (" = %d\n", *ap + *bp); | |
67 | result |= *ap + *bp != 1; | |
68 | if (*ap != 0) | |
69 | { | |
70 | printf ("foo = %d\n", *ap); | |
71 | result = 1; | |
72 | } | |
73 | if (*bp != 1) | |
74 | { | |
75 | printf ("bar = %d\n", *bp); | |
76 | result = 1; | |
77 | } | |
78 | ||
79 | return result; | |
2cef4257 | 80 | } |
aed283dd UD |
81 | |
82 | ||
83 | #include "../test-skeleton.c" |