1 |
297 |
jeremybenn |
/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */
|
2 |
|
|
/* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */
|
3 |
|
|
|
4 |
|
|
/* Validate that each of the __sync builtins compiles. This won't
|
5 |
|
|
necessarily link, since the target might not support the builtin,
|
6 |
|
|
so this may result in external library calls. */
|
7 |
|
|
|
8 |
|
|
signed char sc;
|
9 |
|
|
unsigned char uc;
|
10 |
|
|
signed short ss;
|
11 |
|
|
unsigned short us;
|
12 |
|
|
signed int si;
|
13 |
|
|
unsigned int ui;
|
14 |
|
|
signed long sl;
|
15 |
|
|
unsigned long ul;
|
16 |
|
|
signed long long sll;
|
17 |
|
|
unsigned long long ull;
|
18 |
|
|
void *vp;
|
19 |
|
|
int *ip;
|
20 |
|
|
struct S { struct S *next; int x; } *sp;
|
21 |
|
|
|
22 |
|
|
void test_op_ignore (void)
|
23 |
|
|
{
|
24 |
|
|
(void) __sync_fetch_and_add (&sc, 1);
|
25 |
|
|
(void) __sync_fetch_and_add (&uc, 1);
|
26 |
|
|
(void) __sync_fetch_and_add (&ss, 1);
|
27 |
|
|
(void) __sync_fetch_and_add (&us, 1);
|
28 |
|
|
(void) __sync_fetch_and_add (&si, 1);
|
29 |
|
|
(void) __sync_fetch_and_add (&ui, 1);
|
30 |
|
|
(void) __sync_fetch_and_add (&sl, 1);
|
31 |
|
|
(void) __sync_fetch_and_add (&ul, 1);
|
32 |
|
|
(void) __sync_fetch_and_add (&sll, 1);
|
33 |
|
|
(void) __sync_fetch_and_add (&ull, 1);
|
34 |
|
|
|
35 |
|
|
(void) __sync_fetch_and_sub (&sc, 1);
|
36 |
|
|
(void) __sync_fetch_and_sub (&uc, 1);
|
37 |
|
|
(void) __sync_fetch_and_sub (&ss, 1);
|
38 |
|
|
(void) __sync_fetch_and_sub (&us, 1);
|
39 |
|
|
(void) __sync_fetch_and_sub (&si, 1);
|
40 |
|
|
(void) __sync_fetch_and_sub (&ui, 1);
|
41 |
|
|
(void) __sync_fetch_and_sub (&sl, 1);
|
42 |
|
|
(void) __sync_fetch_and_sub (&ul, 1);
|
43 |
|
|
(void) __sync_fetch_and_sub (&sll, 1);
|
44 |
|
|
(void) __sync_fetch_and_sub (&ull, 1);
|
45 |
|
|
|
46 |
|
|
(void) __sync_fetch_and_or (&sc, 1);
|
47 |
|
|
(void) __sync_fetch_and_or (&uc, 1);
|
48 |
|
|
(void) __sync_fetch_and_or (&ss, 1);
|
49 |
|
|
(void) __sync_fetch_and_or (&us, 1);
|
50 |
|
|
(void) __sync_fetch_and_or (&si, 1);
|
51 |
|
|
(void) __sync_fetch_and_or (&ui, 1);
|
52 |
|
|
(void) __sync_fetch_and_or (&sl, 1);
|
53 |
|
|
(void) __sync_fetch_and_or (&ul, 1);
|
54 |
|
|
(void) __sync_fetch_and_or (&sll, 1);
|
55 |
|
|
(void) __sync_fetch_and_or (&ull, 1);
|
56 |
|
|
|
57 |
|
|
(void) __sync_fetch_and_xor (&sc, 1);
|
58 |
|
|
(void) __sync_fetch_and_xor (&uc, 1);
|
59 |
|
|
(void) __sync_fetch_and_xor (&ss, 1);
|
60 |
|
|
(void) __sync_fetch_and_xor (&us, 1);
|
61 |
|
|
(void) __sync_fetch_and_xor (&si, 1);
|
62 |
|
|
(void) __sync_fetch_and_xor (&ui, 1);
|
63 |
|
|
(void) __sync_fetch_and_xor (&sl, 1);
|
64 |
|
|
(void) __sync_fetch_and_xor (&ul, 1);
|
65 |
|
|
(void) __sync_fetch_and_xor (&sll, 1);
|
66 |
|
|
(void) __sync_fetch_and_xor (&ull, 1);
|
67 |
|
|
|
68 |
|
|
(void) __sync_fetch_and_and (&sc, 1);
|
69 |
|
|
(void) __sync_fetch_and_and (&uc, 1);
|
70 |
|
|
(void) __sync_fetch_and_and (&ss, 1);
|
71 |
|
|
(void) __sync_fetch_and_and (&us, 1);
|
72 |
|
|
(void) __sync_fetch_and_and (&si, 1);
|
73 |
|
|
(void) __sync_fetch_and_and (&ui, 1);
|
74 |
|
|
(void) __sync_fetch_and_and (&sl, 1);
|
75 |
|
|
(void) __sync_fetch_and_and (&ul, 1);
|
76 |
|
|
(void) __sync_fetch_and_and (&sll, 1);
|
77 |
|
|
(void) __sync_fetch_and_and (&ull, 1);
|
78 |
|
|
|
79 |
|
|
(void) __sync_fetch_and_nand (&sc, 1);
|
80 |
|
|
(void) __sync_fetch_and_nand (&uc, 1);
|
81 |
|
|
(void) __sync_fetch_and_nand (&ss, 1);
|
82 |
|
|
(void) __sync_fetch_and_nand (&us, 1);
|
83 |
|
|
(void) __sync_fetch_and_nand (&si, 1);
|
84 |
|
|
(void) __sync_fetch_and_nand (&ui, 1);
|
85 |
|
|
(void) __sync_fetch_and_nand (&sl, 1);
|
86 |
|
|
(void) __sync_fetch_and_nand (&ul, 1);
|
87 |
|
|
(void) __sync_fetch_and_nand (&sll, 1);
|
88 |
|
|
(void) __sync_fetch_and_nand (&ull, 1);
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
void test_fetch_and_op (void)
|
92 |
|
|
{
|
93 |
|
|
sc = __sync_fetch_and_add (&sc, 11);
|
94 |
|
|
uc = __sync_fetch_and_add (&uc, 11);
|
95 |
|
|
ss = __sync_fetch_and_add (&ss, 11);
|
96 |
|
|
us = __sync_fetch_and_add (&us, 11);
|
97 |
|
|
si = __sync_fetch_and_add (&si, 11);
|
98 |
|
|
ui = __sync_fetch_and_add (&ui, 11);
|
99 |
|
|
sl = __sync_fetch_and_add (&sl, 11);
|
100 |
|
|
ul = __sync_fetch_and_add (&ul, 11);
|
101 |
|
|
sll = __sync_fetch_and_add (&sll, 11);
|
102 |
|
|
ull = __sync_fetch_and_add (&ull, 11);
|
103 |
|
|
|
104 |
|
|
sc = __sync_fetch_and_sub (&sc, 11);
|
105 |
|
|
uc = __sync_fetch_and_sub (&uc, 11);
|
106 |
|
|
ss = __sync_fetch_and_sub (&ss, 11);
|
107 |
|
|
us = __sync_fetch_and_sub (&us, 11);
|
108 |
|
|
si = __sync_fetch_and_sub (&si, 11);
|
109 |
|
|
ui = __sync_fetch_and_sub (&ui, 11);
|
110 |
|
|
sl = __sync_fetch_and_sub (&sl, 11);
|
111 |
|
|
ul = __sync_fetch_and_sub (&ul, 11);
|
112 |
|
|
sll = __sync_fetch_and_sub (&sll, 11);
|
113 |
|
|
ull = __sync_fetch_and_sub (&ull, 11);
|
114 |
|
|
|
115 |
|
|
sc = __sync_fetch_and_or (&sc, 11);
|
116 |
|
|
uc = __sync_fetch_and_or (&uc, 11);
|
117 |
|
|
ss = __sync_fetch_and_or (&ss, 11);
|
118 |
|
|
us = __sync_fetch_and_or (&us, 11);
|
119 |
|
|
si = __sync_fetch_and_or (&si, 11);
|
120 |
|
|
ui = __sync_fetch_and_or (&ui, 11);
|
121 |
|
|
sl = __sync_fetch_and_or (&sl, 11);
|
122 |
|
|
ul = __sync_fetch_and_or (&ul, 11);
|
123 |
|
|
sll = __sync_fetch_and_or (&sll, 11);
|
124 |
|
|
ull = __sync_fetch_and_or (&ull, 11);
|
125 |
|
|
|
126 |
|
|
sc = __sync_fetch_and_xor (&sc, 11);
|
127 |
|
|
uc = __sync_fetch_and_xor (&uc, 11);
|
128 |
|
|
ss = __sync_fetch_and_xor (&ss, 11);
|
129 |
|
|
us = __sync_fetch_and_xor (&us, 11);
|
130 |
|
|
si = __sync_fetch_and_xor (&si, 11);
|
131 |
|
|
ui = __sync_fetch_and_xor (&ui, 11);
|
132 |
|
|
sl = __sync_fetch_and_xor (&sl, 11);
|
133 |
|
|
ul = __sync_fetch_and_xor (&ul, 11);
|
134 |
|
|
sll = __sync_fetch_and_xor (&sll, 11);
|
135 |
|
|
ull = __sync_fetch_and_xor (&ull, 11);
|
136 |
|
|
|
137 |
|
|
sc = __sync_fetch_and_and (&sc, 11);
|
138 |
|
|
uc = __sync_fetch_and_and (&uc, 11);
|
139 |
|
|
ss = __sync_fetch_and_and (&ss, 11);
|
140 |
|
|
us = __sync_fetch_and_and (&us, 11);
|
141 |
|
|
si = __sync_fetch_and_and (&si, 11);
|
142 |
|
|
ui = __sync_fetch_and_and (&ui, 11);
|
143 |
|
|
sl = __sync_fetch_and_and (&sl, 11);
|
144 |
|
|
ul = __sync_fetch_and_and (&ul, 11);
|
145 |
|
|
sll = __sync_fetch_and_and (&sll, 11);
|
146 |
|
|
ull = __sync_fetch_and_and (&ull, 11);
|
147 |
|
|
|
148 |
|
|
sc = __sync_fetch_and_nand (&sc, 11);
|
149 |
|
|
uc = __sync_fetch_and_nand (&uc, 11);
|
150 |
|
|
ss = __sync_fetch_and_nand (&ss, 11);
|
151 |
|
|
us = __sync_fetch_and_nand (&us, 11);
|
152 |
|
|
si = __sync_fetch_and_nand (&si, 11);
|
153 |
|
|
ui = __sync_fetch_and_nand (&ui, 11);
|
154 |
|
|
sl = __sync_fetch_and_nand (&sl, 11);
|
155 |
|
|
ul = __sync_fetch_and_nand (&ul, 11);
|
156 |
|
|
sll = __sync_fetch_and_nand (&sll, 11);
|
157 |
|
|
ull = __sync_fetch_and_nand (&ull, 11);
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
void test_op_and_fetch (void)
|
161 |
|
|
{
|
162 |
|
|
sc = __sync_add_and_fetch (&sc, uc);
|
163 |
|
|
uc = __sync_add_and_fetch (&uc, uc);
|
164 |
|
|
ss = __sync_add_and_fetch (&ss, uc);
|
165 |
|
|
us = __sync_add_and_fetch (&us, uc);
|
166 |
|
|
si = __sync_add_and_fetch (&si, uc);
|
167 |
|
|
ui = __sync_add_and_fetch (&ui, uc);
|
168 |
|
|
sl = __sync_add_and_fetch (&sl, uc);
|
169 |
|
|
ul = __sync_add_and_fetch (&ul, uc);
|
170 |
|
|
sll = __sync_add_and_fetch (&sll, uc);
|
171 |
|
|
ull = __sync_add_and_fetch (&ull, uc);
|
172 |
|
|
|
173 |
|
|
sc = __sync_sub_and_fetch (&sc, uc);
|
174 |
|
|
uc = __sync_sub_and_fetch (&uc, uc);
|
175 |
|
|
ss = __sync_sub_and_fetch (&ss, uc);
|
176 |
|
|
us = __sync_sub_and_fetch (&us, uc);
|
177 |
|
|
si = __sync_sub_and_fetch (&si, uc);
|
178 |
|
|
ui = __sync_sub_and_fetch (&ui, uc);
|
179 |
|
|
sl = __sync_sub_and_fetch (&sl, uc);
|
180 |
|
|
ul = __sync_sub_and_fetch (&ul, uc);
|
181 |
|
|
sll = __sync_sub_and_fetch (&sll, uc);
|
182 |
|
|
ull = __sync_sub_and_fetch (&ull, uc);
|
183 |
|
|
|
184 |
|
|
sc = __sync_or_and_fetch (&sc, uc);
|
185 |
|
|
uc = __sync_or_and_fetch (&uc, uc);
|
186 |
|
|
ss = __sync_or_and_fetch (&ss, uc);
|
187 |
|
|
us = __sync_or_and_fetch (&us, uc);
|
188 |
|
|
si = __sync_or_and_fetch (&si, uc);
|
189 |
|
|
ui = __sync_or_and_fetch (&ui, uc);
|
190 |
|
|
sl = __sync_or_and_fetch (&sl, uc);
|
191 |
|
|
ul = __sync_or_and_fetch (&ul, uc);
|
192 |
|
|
sll = __sync_or_and_fetch (&sll, uc);
|
193 |
|
|
ull = __sync_or_and_fetch (&ull, uc);
|
194 |
|
|
|
195 |
|
|
sc = __sync_xor_and_fetch (&sc, uc);
|
196 |
|
|
uc = __sync_xor_and_fetch (&uc, uc);
|
197 |
|
|
ss = __sync_xor_and_fetch (&ss, uc);
|
198 |
|
|
us = __sync_xor_and_fetch (&us, uc);
|
199 |
|
|
si = __sync_xor_and_fetch (&si, uc);
|
200 |
|
|
ui = __sync_xor_and_fetch (&ui, uc);
|
201 |
|
|
sl = __sync_xor_and_fetch (&sl, uc);
|
202 |
|
|
ul = __sync_xor_and_fetch (&ul, uc);
|
203 |
|
|
sll = __sync_xor_and_fetch (&sll, uc);
|
204 |
|
|
ull = __sync_xor_and_fetch (&ull, uc);
|
205 |
|
|
|
206 |
|
|
sc = __sync_and_and_fetch (&sc, uc);
|
207 |
|
|
uc = __sync_and_and_fetch (&uc, uc);
|
208 |
|
|
ss = __sync_and_and_fetch (&ss, uc);
|
209 |
|
|
us = __sync_and_and_fetch (&us, uc);
|
210 |
|
|
si = __sync_and_and_fetch (&si, uc);
|
211 |
|
|
ui = __sync_and_and_fetch (&ui, uc);
|
212 |
|
|
sl = __sync_and_and_fetch (&sl, uc);
|
213 |
|
|
ul = __sync_and_and_fetch (&ul, uc);
|
214 |
|
|
sll = __sync_and_and_fetch (&sll, uc);
|
215 |
|
|
ull = __sync_and_and_fetch (&ull, uc);
|
216 |
|
|
|
217 |
|
|
sc = __sync_nand_and_fetch (&sc, uc);
|
218 |
|
|
uc = __sync_nand_and_fetch (&uc, uc);
|
219 |
|
|
ss = __sync_nand_and_fetch (&ss, uc);
|
220 |
|
|
us = __sync_nand_and_fetch (&us, uc);
|
221 |
|
|
si = __sync_nand_and_fetch (&si, uc);
|
222 |
|
|
ui = __sync_nand_and_fetch (&ui, uc);
|
223 |
|
|
sl = __sync_nand_and_fetch (&sl, uc);
|
224 |
|
|
ul = __sync_nand_and_fetch (&ul, uc);
|
225 |
|
|
sll = __sync_nand_and_fetch (&sll, uc);
|
226 |
|
|
ull = __sync_nand_and_fetch (&ull, uc);
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
void test_compare_and_swap (void)
|
230 |
|
|
{
|
231 |
|
|
sc = __sync_val_compare_and_swap (&sc, uc, sc);
|
232 |
|
|
uc = __sync_val_compare_and_swap (&uc, uc, sc);
|
233 |
|
|
ss = __sync_val_compare_and_swap (&ss, uc, sc);
|
234 |
|
|
us = __sync_val_compare_and_swap (&us, uc, sc);
|
235 |
|
|
si = __sync_val_compare_and_swap (&si, uc, sc);
|
236 |
|
|
ui = __sync_val_compare_and_swap (&ui, uc, sc);
|
237 |
|
|
sl = __sync_val_compare_and_swap (&sl, uc, sc);
|
238 |
|
|
ul = __sync_val_compare_and_swap (&ul, uc, sc);
|
239 |
|
|
sll = __sync_val_compare_and_swap (&sll, uc, sc);
|
240 |
|
|
ull = __sync_val_compare_and_swap (&ull, uc, sc);
|
241 |
|
|
|
242 |
|
|
ui = __sync_bool_compare_and_swap (&sc, uc, sc);
|
243 |
|
|
ui = __sync_bool_compare_and_swap (&uc, uc, sc);
|
244 |
|
|
ui = __sync_bool_compare_and_swap (&ss, uc, sc);
|
245 |
|
|
ui = __sync_bool_compare_and_swap (&us, uc, sc);
|
246 |
|
|
ui = __sync_bool_compare_and_swap (&si, uc, sc);
|
247 |
|
|
ui = __sync_bool_compare_and_swap (&ui, uc, sc);
|
248 |
|
|
ui = __sync_bool_compare_and_swap (&sl, uc, sc);
|
249 |
|
|
ui = __sync_bool_compare_and_swap (&ul, uc, sc);
|
250 |
|
|
ui = __sync_bool_compare_and_swap (&sll, uc, sc);
|
251 |
|
|
ui = __sync_bool_compare_and_swap (&ull, uc, sc);
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
void test_lock (void)
|
255 |
|
|
{
|
256 |
|
|
sc = __sync_lock_test_and_set (&sc, 1);
|
257 |
|
|
uc = __sync_lock_test_and_set (&uc, 1);
|
258 |
|
|
ss = __sync_lock_test_and_set (&ss, 1);
|
259 |
|
|
us = __sync_lock_test_and_set (&us, 1);
|
260 |
|
|
si = __sync_lock_test_and_set (&si, 1);
|
261 |
|
|
ui = __sync_lock_test_and_set (&ui, 1);
|
262 |
|
|
sl = __sync_lock_test_and_set (&sl, 1);
|
263 |
|
|
ul = __sync_lock_test_and_set (&ul, 1);
|
264 |
|
|
sll = __sync_lock_test_and_set (&sll, 1);
|
265 |
|
|
ull = __sync_lock_test_and_set (&ull, 1);
|
266 |
|
|
|
267 |
|
|
__sync_synchronize ();
|
268 |
|
|
|
269 |
|
|
__sync_lock_release (&sc);
|
270 |
|
|
__sync_lock_release (&uc);
|
271 |
|
|
__sync_lock_release (&ss);
|
272 |
|
|
__sync_lock_release (&us);
|
273 |
|
|
__sync_lock_release (&si);
|
274 |
|
|
__sync_lock_release (&ui);
|
275 |
|
|
__sync_lock_release (&sl);
|
276 |
|
|
__sync_lock_release (&ul);
|
277 |
|
|
__sync_lock_release (&sll);
|
278 |
|
|
__sync_lock_release (&ull);
|
279 |
|
|
}
|