v2 / thirdparty / libatomic_ops / atomic_ops / generalize-small.template
528 lines · 481 sloc · 20.5 KB · 90d9b200f999f611a27b604e7b26c76843fb8b7b
Raw
1/*
2 * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23/* XSIZE_fetch_compare_and_swap */
24#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap) \
25 && defined(AO_HAVE_nop_full) \
26 && !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire)
27 AO_INLINE XCTYPE
28 AO_XSIZE_fetch_compare_and_swap_acquire(volatile XCTYPE *addr,
29 XCTYPE old_val, XCTYPE new_val)
30 {
31 XCTYPE result = AO_XSIZE_fetch_compare_and_swap(addr, old_val, new_val);
32 AO_nop_full();
33 return result;
34 }
35# define AO_HAVE_XSIZE_fetch_compare_and_swap_acquire
36#endif
37#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap) \
38 && defined(AO_HAVE_nop_full) \
39 && !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_release)
40# define AO_XSIZE_fetch_compare_and_swap_release(addr, old_val, new_val) \
41 (AO_nop_full(), \
42 AO_XSIZE_fetch_compare_and_swap(addr, old_val, new_val))
43# define AO_HAVE_XSIZE_fetch_compare_and_swap_release
44#endif
45#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap_full)
46# if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_release)
47# define AO_XSIZE_fetch_compare_and_swap_release(addr, old_val, new_val) \
48 AO_XSIZE_fetch_compare_and_swap_full(addr, old_val, new_val)
49# define AO_HAVE_XSIZE_fetch_compare_and_swap_release
50# endif
51# if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire)
52# define AO_XSIZE_fetch_compare_and_swap_acquire(addr, old_val, new_val) \
53 AO_XSIZE_fetch_compare_and_swap_full(addr, old_val, new_val)
54# define AO_HAVE_XSIZE_fetch_compare_and_swap_acquire
55# endif
56# if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_write)
57# define AO_XSIZE_fetch_compare_and_swap_write(addr, old_val, new_val) \
58 AO_XSIZE_fetch_compare_and_swap_full(addr, old_val, new_val)
59# define AO_HAVE_XSIZE_fetch_compare_and_swap_write
60# endif
61# if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_read)
62# define AO_XSIZE_fetch_compare_and_swap_read(addr, old_val, new_val) \
63 AO_XSIZE_fetch_compare_and_swap_full(addr, old_val, new_val)
64# define AO_HAVE_XSIZE_fetch_compare_and_swap_read
65# endif
66#endif /* AO_HAVE_XSIZE_fetch_compare_and_swap_full */
67
68#if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap) \
69 && defined(AO_HAVE_XSIZE_fetch_compare_and_swap_release)
70# define AO_XSIZE_fetch_compare_and_swap(addr, old_val, new_val) \
71 AO_XSIZE_fetch_compare_and_swap_release(addr, old_val, new_val)
72# define AO_HAVE_XSIZE_fetch_compare_and_swap
73#endif
74#if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap) \
75 && defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire)
76# define AO_XSIZE_fetch_compare_and_swap(addr, old_val, new_val) \
77 AO_XSIZE_fetch_compare_and_swap_acquire(addr, old_val, new_val)
78# define AO_HAVE_XSIZE_fetch_compare_and_swap
79#endif
80#if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap) \
81 && defined(AO_HAVE_XSIZE_fetch_compare_and_swap_write)
82# define AO_XSIZE_fetch_compare_and_swap(addr, old_val, new_val) \
83 AO_XSIZE_fetch_compare_and_swap_write(addr, old_val, new_val)
84# define AO_HAVE_XSIZE_fetch_compare_and_swap
85#endif
86#if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap) \
87 && defined(AO_HAVE_XSIZE_fetch_compare_and_swap_read)
88# define AO_XSIZE_fetch_compare_and_swap(addr, old_val, new_val) \
89 AO_XSIZE_fetch_compare_and_swap_read(addr, old_val, new_val)
90# define AO_HAVE_XSIZE_fetch_compare_and_swap
91#endif
92
93#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire) \
94 && defined(AO_HAVE_nop_full) \
95 && !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_full)
96# define AO_XSIZE_fetch_compare_and_swap_full(addr, old_val, new_val) \
97 (AO_nop_full(), \
98 AO_XSIZE_fetch_compare_and_swap_acquire(addr, old_val, new_val))
99# define AO_HAVE_XSIZE_fetch_compare_and_swap_full
100#endif
101
102#if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_release_write) \
103 && defined(AO_HAVE_XSIZE_fetch_compare_and_swap_write)
104# define AO_XSIZE_fetch_compare_and_swap_release_write(addr,old_val,new_val) \
105 AO_XSIZE_fetch_compare_and_swap_write(addr, old_val, new_val)
106# define AO_HAVE_XSIZE_fetch_compare_and_swap_release_write
107#endif
108#if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_release_write) \
109 && defined(AO_HAVE_XSIZE_fetch_compare_and_swap_release)
110# define AO_XSIZE_fetch_compare_and_swap_release_write(addr,old_val,new_val) \
111 AO_XSIZE_fetch_compare_and_swap_release(addr, old_val, new_val)
112# define AO_HAVE_XSIZE_fetch_compare_and_swap_release_write
113#endif
114#if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire_read) \
115 && defined(AO_HAVE_XSIZE_fetch_compare_and_swap_read)
116# define AO_XSIZE_fetch_compare_and_swap_acquire_read(addr,old_val,new_val) \
117 AO_XSIZE_fetch_compare_and_swap_read(addr, old_val, new_val)
118# define AO_HAVE_XSIZE_fetch_compare_and_swap_acquire_read
119#endif
120#if !defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire_read) \
121 && defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire)
122# define AO_XSIZE_fetch_compare_and_swap_acquire_read(addr,old_val,new_val) \
123 AO_XSIZE_fetch_compare_and_swap_acquire(addr, old_val, new_val)
124# define AO_HAVE_XSIZE_fetch_compare_and_swap_acquire_read
125#endif
126
127#ifdef AO_NO_DD_ORDERING
128# if defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire_read)
129# define AO_XSIZE_fetch_compare_and_swap_dd_acquire_read(addr,old_val,new_val) \
130 AO_XSIZE_fetch_compare_and_swap_acquire_read(addr, old_val, new_val)
131# define AO_HAVE_XSIZE_fetch_compare_and_swap_dd_acquire_read
132# endif
133#else
134# if defined(AO_HAVE_XSIZE_fetch_compare_and_swap)
135# define AO_XSIZE_fetch_compare_and_swap_dd_acquire_read(addr,old_val,new_val) \
136 AO_XSIZE_fetch_compare_and_swap(addr, old_val, new_val)
137# define AO_HAVE_XSIZE_fetch_compare_and_swap_dd_acquire_read
138# endif
139#endif /* !AO_NO_DD_ORDERING */
140
141/* XSIZE_compare_and_swap */
142#if defined(AO_HAVE_XSIZE_compare_and_swap) && defined(AO_HAVE_nop_full) \
143 && !defined(AO_HAVE_XSIZE_compare_and_swap_acquire)
144 AO_INLINE int
145 AO_XSIZE_compare_and_swap_acquire(volatile XCTYPE *addr, XCTYPE old,
146 XCTYPE new_val)
147 {
148 int result = AO_XSIZE_compare_and_swap(addr, old, new_val);
149 AO_nop_full();
150 return result;
151 }
152# define AO_HAVE_XSIZE_compare_and_swap_acquire
153#endif
154#if defined(AO_HAVE_XSIZE_compare_and_swap) && defined(AO_HAVE_nop_full) \
155 && !defined(AO_HAVE_XSIZE_compare_and_swap_release)
156# define AO_XSIZE_compare_and_swap_release(addr, old, new_val) \
157 (AO_nop_full(), AO_XSIZE_compare_and_swap(addr, old, new_val))
158# define AO_HAVE_XSIZE_compare_and_swap_release
159#endif
160#if defined(AO_HAVE_XSIZE_compare_and_swap_full)
161# if !defined(AO_HAVE_XSIZE_compare_and_swap_release)
162# define AO_XSIZE_compare_and_swap_release(addr, old, new_val) \
163 AO_XSIZE_compare_and_swap_full(addr, old, new_val)
164# define AO_HAVE_XSIZE_compare_and_swap_release
165# endif
166# if !defined(AO_HAVE_XSIZE_compare_and_swap_acquire)
167# define AO_XSIZE_compare_and_swap_acquire(addr, old, new_val) \
168 AO_XSIZE_compare_and_swap_full(addr, old, new_val)
169# define AO_HAVE_XSIZE_compare_and_swap_acquire
170# endif
171# if !defined(AO_HAVE_XSIZE_compare_and_swap_write)
172# define AO_XSIZE_compare_and_swap_write(addr, old, new_val) \
173 AO_XSIZE_compare_and_swap_full(addr, old, new_val)
174# define AO_HAVE_XSIZE_compare_and_swap_write
175# endif
176# if !defined(AO_HAVE_XSIZE_compare_and_swap_read)
177# define AO_XSIZE_compare_and_swap_read(addr, old, new_val) \
178 AO_XSIZE_compare_and_swap_full(addr, old, new_val)
179# define AO_HAVE_XSIZE_compare_and_swap_read
180# endif
181#endif /* AO_HAVE_XSIZE_compare_and_swap_full */
182
183#if !defined(AO_HAVE_XSIZE_compare_and_swap) \
184 && defined(AO_HAVE_XSIZE_compare_and_swap_release)
185# define AO_XSIZE_compare_and_swap(addr, old, new_val) \
186 AO_XSIZE_compare_and_swap_release(addr, old, new_val)
187# define AO_HAVE_XSIZE_compare_and_swap
188#endif
189#if !defined(AO_HAVE_XSIZE_compare_and_swap) \
190 && defined(AO_HAVE_XSIZE_compare_and_swap_acquire)
191# define AO_XSIZE_compare_and_swap(addr, old, new_val) \
192 AO_XSIZE_compare_and_swap_acquire(addr, old, new_val)
193# define AO_HAVE_XSIZE_compare_and_swap
194#endif
195#if !defined(AO_HAVE_XSIZE_compare_and_swap) \
196 && defined(AO_HAVE_XSIZE_compare_and_swap_write)
197# define AO_XSIZE_compare_and_swap(addr, old, new_val) \
198 AO_XSIZE_compare_and_swap_write(addr, old, new_val)
199# define AO_HAVE_XSIZE_compare_and_swap
200#endif
201#if !defined(AO_HAVE_XSIZE_compare_and_swap) \
202 && defined(AO_HAVE_XSIZE_compare_and_swap_read)
203# define AO_XSIZE_compare_and_swap(addr, old, new_val) \
204 AO_XSIZE_compare_and_swap_read(addr, old, new_val)
205# define AO_HAVE_XSIZE_compare_and_swap
206#endif
207
208#if defined(AO_HAVE_XSIZE_compare_and_swap_acquire) \
209 && defined(AO_HAVE_nop_full) \
210 && !defined(AO_HAVE_XSIZE_compare_and_swap_full)
211# define AO_XSIZE_compare_and_swap_full(addr, old, new_val) \
212 (AO_nop_full(), \
213 AO_XSIZE_compare_and_swap_acquire(addr, old, new_val))
214# define AO_HAVE_XSIZE_compare_and_swap_full
215#endif
216
217#if !defined(AO_HAVE_XSIZE_compare_and_swap_release_write) \
218 && defined(AO_HAVE_XSIZE_compare_and_swap_write)
219# define AO_XSIZE_compare_and_swap_release_write(addr, old, new_val) \
220 AO_XSIZE_compare_and_swap_write(addr, old, new_val)
221# define AO_HAVE_XSIZE_compare_and_swap_release_write
222#endif
223#if !defined(AO_HAVE_XSIZE_compare_and_swap_release_write) \
224 && defined(AO_HAVE_XSIZE_compare_and_swap_release)
225# define AO_XSIZE_compare_and_swap_release_write(addr, old, new_val) \
226 AO_XSIZE_compare_and_swap_release(addr, old, new_val)
227# define AO_HAVE_XSIZE_compare_and_swap_release_write
228#endif
229#if !defined(AO_HAVE_XSIZE_compare_and_swap_acquire_read) \
230 && defined(AO_HAVE_XSIZE_compare_and_swap_read)
231# define AO_XSIZE_compare_and_swap_acquire_read(addr, old, new_val) \
232 AO_XSIZE_compare_and_swap_read(addr, old, new_val)
233# define AO_HAVE_XSIZE_compare_and_swap_acquire_read
234#endif
235#if !defined(AO_HAVE_XSIZE_compare_and_swap_acquire_read) \
236 && defined(AO_HAVE_XSIZE_compare_and_swap_acquire)
237# define AO_XSIZE_compare_and_swap_acquire_read(addr, old, new_val) \
238 AO_XSIZE_compare_and_swap_acquire(addr, old, new_val)
239# define AO_HAVE_XSIZE_compare_and_swap_acquire_read
240#endif
241
242#ifdef AO_NO_DD_ORDERING
243# if defined(AO_HAVE_XSIZE_compare_and_swap_acquire_read)
244# define AO_XSIZE_compare_and_swap_dd_acquire_read(addr, old, new_val) \
245 AO_XSIZE_compare_and_swap_acquire_read(addr, old, new_val)
246# define AO_HAVE_XSIZE_compare_and_swap_dd_acquire_read
247# endif
248#else
249# if defined(AO_HAVE_XSIZE_compare_and_swap)
250# define AO_XSIZE_compare_and_swap_dd_acquire_read(addr, old, new_val) \
251 AO_XSIZE_compare_and_swap(addr, old, new_val)
252# define AO_HAVE_XSIZE_compare_and_swap_dd_acquire_read
253# endif
254#endif /* !AO_NO_DD_ORDERING */
255
256/* XSIZE_load */
257#if defined(AO_HAVE_XSIZE_load_full) && !defined(AO_HAVE_XSIZE_load_acquire)
258# define AO_XSIZE_load_acquire(addr) AO_XSIZE_load_full(addr)
259# define AO_HAVE_XSIZE_load_acquire
260#endif
261
262#if defined(AO_HAVE_XSIZE_load_acquire) && !defined(AO_HAVE_XSIZE_load)
263# define AO_XSIZE_load(addr) AO_XSIZE_load_acquire(addr)
264# define AO_HAVE_XSIZE_load
265#endif
266
267#if defined(AO_HAVE_XSIZE_load_full) && !defined(AO_HAVE_XSIZE_load_read)
268# define AO_XSIZE_load_read(addr) AO_XSIZE_load_full(addr)
269# define AO_HAVE_XSIZE_load_read
270#endif
271
272#if !defined(AO_HAVE_XSIZE_load_acquire_read) \
273 && defined(AO_HAVE_XSIZE_load_acquire)
274# define AO_XSIZE_load_acquire_read(addr) AO_XSIZE_load_acquire(addr)
275# define AO_HAVE_XSIZE_load_acquire_read
276#endif
277
278#if defined(AO_HAVE_XSIZE_load) && defined(AO_HAVE_nop_full) \
279 && !defined(AO_HAVE_XSIZE_load_acquire)
280 AO_INLINE XCTYPE
281 AO_XSIZE_load_acquire(const volatile XCTYPE *addr)
282 {
283 XCTYPE result = AO_XSIZE_load(addr);
284
285 /* Acquire barrier would be useless, since the load could be delayed */
286 /* beyond it. */
287 AO_nop_full();
288 return result;
289 }
290# define AO_HAVE_XSIZE_load_acquire
291#endif
292
293#if defined(AO_HAVE_XSIZE_load) && defined(AO_HAVE_nop_read) \
294 && !defined(AO_HAVE_XSIZE_load_read)
295 AO_INLINE XCTYPE
296 AO_XSIZE_load_read(const volatile XCTYPE *addr)
297 {
298 XCTYPE result = AO_XSIZE_load(addr);
299
300 AO_nop_read();
301 return result;
302 }
303# define AO_HAVE_XSIZE_load_read
304#endif
305
306#if defined(AO_HAVE_XSIZE_load_acquire) && defined(AO_HAVE_nop_full) \
307 && !defined(AO_HAVE_XSIZE_load_full)
308# define AO_XSIZE_load_full(addr) (AO_nop_full(), AO_XSIZE_load_acquire(addr))
309# define AO_HAVE_XSIZE_load_full
310#endif
311
312#if defined(AO_HAVE_XSIZE_compare_and_swap_read) \
313 && !defined(AO_HAVE_XSIZE_load_read)
314# define AO_XSIZE_CAS_BASED_LOAD_READ
315 AO_ATTR_NO_SANITIZE_THREAD
316 AO_INLINE XCTYPE
317 AO_XSIZE_load_read(const volatile XCTYPE *addr)
318 {
319 XCTYPE result;
320
321 do {
322 result = *(const XCTYPE *)addr;
323 } while (AO_EXPECT_FALSE(!AO_XSIZE_compare_and_swap_read(
324 (volatile XCTYPE *)addr,
325 result, result)));
326 return result;
327 }
328# define AO_HAVE_XSIZE_load_read
329#endif
330
331#if !defined(AO_HAVE_XSIZE_load_acquire_read) \
332 && defined(AO_HAVE_XSIZE_load_read)
333# define AO_XSIZE_load_acquire_read(addr) AO_XSIZE_load_read(addr)
334# define AO_HAVE_XSIZE_load_acquire_read
335#endif
336
337#if defined(AO_HAVE_XSIZE_load_acquire_read) && !defined(AO_HAVE_XSIZE_load) \
338 && (!defined(AO_XSIZE_CAS_BASED_LOAD_READ) \
339 || !defined(AO_HAVE_XSIZE_compare_and_swap))
340# define AO_XSIZE_load(addr) AO_XSIZE_load_acquire_read(addr)
341# define AO_HAVE_XSIZE_load
342#endif
343
344#if defined(AO_HAVE_XSIZE_compare_and_swap_full) \
345 && !defined(AO_HAVE_XSIZE_load_full)
346 AO_ATTR_NO_SANITIZE_THREAD
347 AO_INLINE XCTYPE
348 AO_XSIZE_load_full(const volatile XCTYPE *addr)
349 {
350 XCTYPE result;
351
352 do {
353 result = *(const XCTYPE *)addr;
354 } while (AO_EXPECT_FALSE(!AO_XSIZE_compare_and_swap_full(
355 (volatile XCTYPE *)addr,
356 result, result)));
357 return result;
358 }
359# define AO_HAVE_XSIZE_load_full
360#endif
361
362#if defined(AO_HAVE_XSIZE_compare_and_swap_acquire) \
363 && !defined(AO_HAVE_XSIZE_load_acquire)
364 AO_ATTR_NO_SANITIZE_THREAD
365 AO_INLINE XCTYPE
366 AO_XSIZE_load_acquire(const volatile XCTYPE *addr)
367 {
368 XCTYPE result;
369
370 do {
371 result = *(const XCTYPE *)addr;
372 } while (AO_EXPECT_FALSE(!AO_XSIZE_compare_and_swap_acquire(
373 (volatile XCTYPE *)addr,
374 result, result)));
375 return result;
376 }
377# define AO_HAVE_XSIZE_load_acquire
378#endif
379
380#if defined(AO_HAVE_XSIZE_compare_and_swap) && !defined(AO_HAVE_XSIZE_load)
381 AO_ATTR_NO_SANITIZE_THREAD
382 AO_INLINE XCTYPE
383 AO_XSIZE_load(const volatile XCTYPE *addr)
384 {
385 XCTYPE result;
386
387 do {
388 result = *(const XCTYPE *)addr;
389 } while (AO_EXPECT_FALSE(!AO_XSIZE_compare_and_swap(
390 (volatile XCTYPE *)addr,
391 result, result)));
392 return result;
393 }
394# define AO_HAVE_XSIZE_load
395#endif
396
397#ifdef AO_NO_DD_ORDERING
398# if defined(AO_HAVE_XSIZE_load_acquire_read)
399# define AO_XSIZE_load_dd_acquire_read(addr) \
400 AO_XSIZE_load_acquire_read(addr)
401# define AO_HAVE_XSIZE_load_dd_acquire_read
402# endif
403#else
404# if defined(AO_HAVE_XSIZE_load)
405# define AO_XSIZE_load_dd_acquire_read(addr) AO_XSIZE_load(addr)
406# define AO_HAVE_XSIZE_load_dd_acquire_read
407# endif
408#endif /* !AO_NO_DD_ORDERING */
409
410/* XSIZE_store */
411#if defined(AO_HAVE_XSIZE_store_full) && !defined(AO_HAVE_XSIZE_store_release)
412# define AO_XSIZE_store_release(addr, val) AO_XSIZE_store_full(addr, val)
413# define AO_HAVE_XSIZE_store_release
414#endif
415
416#if defined(AO_HAVE_XSIZE_store_release) && !defined(AO_HAVE_XSIZE_store)
417# define AO_XSIZE_store(addr, val) AO_XSIZE_store_release(addr, val)
418# define AO_HAVE_XSIZE_store
419#endif
420
421#if defined(AO_HAVE_XSIZE_store_full) && !defined(AO_HAVE_XSIZE_store_write)
422# define AO_XSIZE_store_write(addr, val) AO_XSIZE_store_full(addr, val)
423# define AO_HAVE_XSIZE_store_write
424#endif
425
426#if defined(AO_HAVE_XSIZE_store_release) \
427 && !defined(AO_HAVE_XSIZE_store_release_write)
428# define AO_XSIZE_store_release_write(addr, val) \
429 AO_XSIZE_store_release(addr, val)
430# define AO_HAVE_XSIZE_store_release_write
431#endif
432
433#if defined(AO_HAVE_XSIZE_store_write) && !defined(AO_HAVE_XSIZE_store)
434# define AO_XSIZE_store(addr, val) AO_XSIZE_store_write(addr, val)
435# define AO_HAVE_XSIZE_store
436#endif
437
438#if defined(AO_HAVE_XSIZE_store) && defined(AO_HAVE_nop_full) \
439 && !defined(AO_HAVE_XSIZE_store_release)
440# define AO_XSIZE_store_release(addr, val) \
441 (AO_nop_full(), AO_XSIZE_store(addr, val))
442# define AO_HAVE_XSIZE_store_release
443#endif
444
445#if defined(AO_HAVE_XSIZE_store) && defined(AO_HAVE_nop_write) \
446 && !defined(AO_HAVE_XSIZE_store_write)
447# define AO_XSIZE_store_write(addr, val) \
448 (AO_nop_write(), AO_XSIZE_store(addr, val))
449# define AO_HAVE_XSIZE_store_write
450#endif
451
452#if defined(AO_HAVE_XSIZE_compare_and_swap_write) \
453 && !defined(AO_HAVE_XSIZE_store_write)
454 AO_ATTR_NO_SANITIZE_MEMORY AO_ATTR_NO_SANITIZE_THREAD
455 AO_INLINE void
456 AO_XSIZE_store_write(volatile XCTYPE *addr, XCTYPE new_val)
457 {
458 XCTYPE old_val;
459
460 do {
461 old_val = *(XCTYPE *)addr;
462 } while (AO_EXPECT_FALSE(!AO_XSIZE_compare_and_swap_write(addr, old_val,
463 new_val)));
464 }
465# define AO_HAVE_XSIZE_store_write
466#endif
467
468#if defined(AO_HAVE_XSIZE_store_write) \
469 && !defined(AO_HAVE_XSIZE_store_release_write)
470# define AO_XSIZE_store_release_write(addr, val) \
471 AO_XSIZE_store_write(addr, val)
472# define AO_HAVE_XSIZE_store_release_write
473#endif
474
475#if defined(AO_HAVE_XSIZE_store_release) && defined(AO_HAVE_nop_full) \
476 && !defined(AO_HAVE_XSIZE_store_full)
477# define AO_XSIZE_store_full(addr, val) \
478 (AO_XSIZE_store_release(addr, val), \
479 AO_nop_full())
480# define AO_HAVE_XSIZE_store_full
481#endif
482
483#if defined(AO_HAVE_XSIZE_compare_and_swap) && !defined(AO_HAVE_XSIZE_store)
484 AO_ATTR_NO_SANITIZE_MEMORY AO_ATTR_NO_SANITIZE_THREAD
485 AO_INLINE void
486 AO_XSIZE_store(volatile XCTYPE *addr, XCTYPE new_val)
487 {
488 XCTYPE old_val;
489
490 do {
491 old_val = *(XCTYPE *)addr;
492 } while (AO_EXPECT_FALSE(!AO_XSIZE_compare_and_swap(addr,
493 old_val, new_val)));
494 }
495# define AO_HAVE_XSIZE_store
496#endif
497
498#if defined(AO_HAVE_XSIZE_compare_and_swap_release) \
499 && !defined(AO_HAVE_XSIZE_store_release)
500 AO_ATTR_NO_SANITIZE_MEMORY AO_ATTR_NO_SANITIZE_THREAD
501 AO_INLINE void
502 AO_XSIZE_store_release(volatile XCTYPE *addr, XCTYPE new_val)
503 {
504 XCTYPE old_val;
505
506 do {
507 old_val = *(XCTYPE *)addr;
508 } while (AO_EXPECT_FALSE(!AO_XSIZE_compare_and_swap_release(addr, old_val,
509 new_val)));
510 }
511# define AO_HAVE_XSIZE_store_release
512#endif
513
514#if defined(AO_HAVE_XSIZE_compare_and_swap_full) \
515 && !defined(AO_HAVE_XSIZE_store_full)
516 AO_ATTR_NO_SANITIZE_MEMORY AO_ATTR_NO_SANITIZE_THREAD
517 AO_INLINE void
518 AO_XSIZE_store_full(volatile XCTYPE *addr, XCTYPE new_val)
519 {
520 XCTYPE old_val;
521
522 do {
523 old_val = *(XCTYPE *)addr;
524 } while (AO_EXPECT_FALSE(!AO_XSIZE_compare_and_swap_full(addr, old_val,
525 new_val)));
526 }
527# define AO_HAVE_XSIZE_store_full
528#endif
529