18#if !defined(AO_GCC_HAVE_char_SYNC_CAS) || !defined(AO_PREFER_GENERALIZED)
23 return __atomic_load_n(addr, __ATOMIC_RELAXED);
25#define AO_HAVE_char_load
30 return __atomic_load_n(addr, __ATOMIC_ACQUIRE);
32#define AO_HAVE_char_load_acquire
49#ifndef AO_SKIPATOMIC_char_store
53 __atomic_store_n(addr, value, __ATOMIC_RELAXED);
55# define AO_HAVE_char_store
58#ifndef AO_SKIPATOMIC_char_store_release
62 __atomic_store_n(addr, value, __ATOMIC_RELEASE);
64# define AO_HAVE_char_store_release
69#ifdef AO_GCC_HAVE_char_SYNC_CAS
72 AO_char_fetch_compare_and_swap(
volatile unsignedchar *addr,
73 unsignedchar old_val,
unsignedchar new_val)
75 (void)__atomic_compare_exchange_n(addr,
83# define AO_HAVE_char_fetch_compare_and_swap
87 unsignedchar old_val,
unsignedchar new_val)
89 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
90 __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
93# define AO_HAVE_char_fetch_compare_and_swap_acquire
97 unsignedchar old_val,
unsignedchar new_val)
99 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
104# define AO_HAVE_char_fetch_compare_and_swap_release
108 unsignedchar old_val,
unsignedchar new_val)
110 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
115# define AO_HAVE_char_fetch_compare_and_swap_full
117# ifndef AO_GENERALIZE_ASM_BOOL_CAS
119 AO_char_compare_and_swap(
volatile unsignedchar *addr,
120 unsignedchar old_val,
unsignedchar new_val)
122 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
123 __ATOMIC_RELAXED, __ATOMIC_RELAXED);
125# define AO_HAVE_char_compare_and_swap
128 AO_char_compare_and_swap_acquire(
volatile unsignedchar *addr,
129 unsignedchar old_val,
unsignedchar new_val)
131 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
132 __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
134# define AO_HAVE_char_compare_and_swap_acquire
137 AO_char_compare_and_swap_release(
volatile unsignedchar *addr,
138 unsignedchar old_val,
unsignedchar new_val)
140 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
144# define AO_HAVE_char_compare_and_swap_release
147 AO_char_compare_and_swap_full(
volatile unsignedchar *addr,
148 unsignedchar old_val,
unsignedchar new_val)
150 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
154# define AO_HAVE_char_compare_and_swap_full
176#if !defined(AO_GCC_HAVE_short_SYNC_CAS) || !defined(AO_PREFER_GENERALIZED)
181 return __atomic_load_n(addr, __ATOMIC_RELAXED);
183#define AO_HAVE_short_load
188 return __atomic_load_n(addr, __ATOMIC_ACQUIRE);
190#define AO_HAVE_short_load_acquire
207#ifndef AO_SKIPATOMIC_short_store
211 __atomic_store_n(addr, value, __ATOMIC_RELAXED);
213# define AO_HAVE_short_store
216#ifndef AO_SKIPATOMIC_short_store_release
220 __atomic_store_n(addr, value, __ATOMIC_RELEASE);
222# define AO_HAVE_short_store_release
227#ifdef AO_GCC_HAVE_short_SYNC_CAS
230 AO_short_fetch_compare_and_swap(
volatile unsignedshort *addr,
231 unsignedshort old_val,
unsignedshort new_val)
233 (void)__atomic_compare_exchange_n(addr,
241# define AO_HAVE_short_fetch_compare_and_swap
245 unsignedshort old_val,
unsignedshort new_val)
247 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
248 __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
251# define AO_HAVE_short_fetch_compare_and_swap_acquire
255 unsignedshort old_val,
unsignedshort new_val)
257 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
262# define AO_HAVE_short_fetch_compare_and_swap_release
266 unsignedshort old_val,
unsignedshort new_val)
268 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
273# define AO_HAVE_short_fetch_compare_and_swap_full
275# ifndef AO_GENERALIZE_ASM_BOOL_CAS
277 AO_short_compare_and_swap(
volatile unsignedshort *addr,
278 unsignedshort old_val,
unsignedshort new_val)
280 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
281 __ATOMIC_RELAXED, __ATOMIC_RELAXED);
283# define AO_HAVE_short_compare_and_swap
286 AO_short_compare_and_swap_acquire(
volatile unsignedshort *addr,
287 unsignedshort old_val,
unsignedshort new_val)
289 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
290 __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
292# define AO_HAVE_short_compare_and_swap_acquire
295 AO_short_compare_and_swap_release(
volatile unsignedshort *addr,
296 unsignedshort old_val,
unsignedshort new_val)
298 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
302# define AO_HAVE_short_compare_and_swap_release
305 AO_short_compare_and_swap_full(
volatile unsignedshort *addr,
306 unsignedshort old_val,
unsignedshort new_val)
308 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
312# define AO_HAVE_short_compare_and_swap_full
334#if !defined(AO_GCC_HAVE_int_SYNC_CAS) || !defined(AO_PREFER_GENERALIZED)
339 return __atomic_load_n(addr, __ATOMIC_RELAXED);
341#define AO_HAVE_int_load
346 return __atomic_load_n(addr, __ATOMIC_ACQUIRE);
348#define AO_HAVE_int_load_acquire
365#ifndef AO_SKIPATOMIC_int_store
369 __atomic_store_n(addr, value, __ATOMIC_RELAXED);
371# define AO_HAVE_int_store
374#ifndef AO_SKIPATOMIC_int_store_release
378 __atomic_store_n(addr, value, __ATOMIC_RELEASE);
380# define AO_HAVE_int_store_release
385#ifdef AO_GCC_HAVE_int_SYNC_CAS
388 AO_int_fetch_compare_and_swap(
volatile unsigned *addr,
389 unsigned old_val,
unsigned new_val)
391 (void)__atomic_compare_exchange_n(addr,
399# define AO_HAVE_int_fetch_compare_and_swap
403 unsigned old_val,
unsigned new_val)
405 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
406 __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
409# define AO_HAVE_int_fetch_compare_and_swap_acquire
413 unsigned old_val,
unsigned new_val)
415 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
420# define AO_HAVE_int_fetch_compare_and_swap_release
424 unsigned old_val,
unsigned new_val)
426 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
431# define AO_HAVE_int_fetch_compare_and_swap_full
433# ifndef AO_GENERALIZE_ASM_BOOL_CAS
435 AO_int_compare_and_swap(
volatile unsigned *addr,
436 unsigned old_val,
unsigned new_val)
438 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
439 __ATOMIC_RELAXED, __ATOMIC_RELAXED);
441# define AO_HAVE_int_compare_and_swap
444 AO_int_compare_and_swap_acquire(
volatile unsigned *addr,
445 unsigned old_val,
unsigned new_val)
447 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
448 __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
450# define AO_HAVE_int_compare_and_swap_acquire
453 AO_int_compare_and_swap_release(
volatile unsigned *addr,
454 unsigned old_val,
unsigned new_val)
456 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
460# define AO_HAVE_int_compare_and_swap_release
463 AO_int_compare_and_swap_full(
volatile unsigned *addr,
464 unsigned old_val,
unsigned new_val)
466 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
470# define AO_HAVE_int_compare_and_swap_full
492#if !defined(AO_GCC_HAVE_SYNC_CAS) || !defined(AO_PREFER_GENERALIZED)
497 return __atomic_load_n(addr, __ATOMIC_RELAXED);
504 return __atomic_load_n(addr, __ATOMIC_ACQUIRE);
506#define AO_HAVE_load_acquire
523#ifndef AO_SKIPATOMIC_store
527 __atomic_store_n(addr, value, __ATOMIC_RELAXED);
529# define AO_HAVE_store
532#ifndef AO_SKIPATOMIC_store_release
536 __atomic_store_n(addr, value, __ATOMIC_RELEASE);
538# define AO_HAVE_store_release
543#ifdef AO_GCC_HAVE_SYNC_CAS
549 (void)__atomic_compare_exchange_n(addr,
557# define AO_HAVE_fetch_compare_and_swap
563 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
564 __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
567# define AO_HAVE_fetch_compare_and_swap_acquire
573 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
578# define AO_HAVE_fetch_compare_and_swap_release
584 (void)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
589# define AO_HAVE_fetch_compare_and_swap_full
591# ifndef AO_GENERALIZE_ASM_BOOL_CAS
596 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
597 __ATOMIC_RELAXED, __ATOMIC_RELAXED);
599# define AO_HAVE_compare_and_swap
605 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
606 __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
608# define AO_HAVE_compare_and_swap_acquire
614 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
618# define AO_HAVE_compare_and_swap_release
624 return (
int)__atomic_compare_exchange_n(addr, &old_val, new_val, 0,
628# define AO_HAVE_compare_and_swap_full
AO_INLINE int AO_compare_and_swap(volatile AO_t *addr, AO_t old, AO_t new_val)
AO_INLINE int AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val)
#define AO_fetch_compare_and_swap_full(addr, old, newval)
AO_INLINE AO_t AO_fetch_compare_and_swap(volatile AO_t *addr, AO_t old_val, AO_t new_val)
AO_INLINE unsigned short AO_short_fetch_compare_and_swap_acquire(volatile unsigned short *addr, unsigned short old, unsigned short new_val)
AO_INLINE unsigned char AO_char_fetch_compare_and_swap_acquire(volatile unsigned char *addr, unsigned char old, unsigned char new_val)
AO_INLINE unsigned int AO_int_fetch_compare_and_swap_acquire(volatile unsigned int *addr, unsigned int old, unsigned int new_val)
AO_INLINE unsigned int AO_int_fetch_compare_and_swap_release(volatile unsigned int *addr, unsigned int old, unsigned int new_val)
AO_INLINE AO_t AO_fetch_compare_and_swap_release(volatile AO_t *addr, AO_t old, AO_t new_val)
AO_INLINE unsigned short AO_short_fetch_compare_and_swap_release(volatile unsigned short *addr, unsigned short old, unsigned short new_val)
AO_INLINE unsigned char AO_char_fetch_compare_and_swap_release(volatile unsigned char *addr, unsigned char old, unsigned char new_val)
AO_INLINE AO_t AO_fetch_compare_and_swap_acquire(volatile AO_t *addr, AO_t old, AO_t new_val)
AO_INLINE int AO_compare_and_swap_acquire(volatile AO_t *addr, AO_t old, AO_t new_val)
AO_INLINE int AO_compare_and_swap_release(volatile AO_t *addr, AO_t old, AO_t new_val)
AO_INLINE unsigned short AO_short_fetch_compare_and_swap_full(volatile unsigned short *addr, unsigned short old_val, unsigned short new_val)
AO_INLINE unsigned char AO_char_fetch_compare_and_swap_full(volatile unsigned char *addr, unsigned char old_val, unsigned char new_val)
AO_INLINE void AO_char_store(volatile unsignedchar *addr, unsignedchar value)
AO_INLINE unsigned short AO_short_load(const volatile unsignedshort *addr)
AO_INLINE unsigned AO_int_load_acquire(const volatile unsigned *addr)
AO_INLINE void AO_store_release(volatile AO_t *addr, AO_t value)
AO_INLINE unsigned AO_int_load(const volatile unsigned *addr)
AO_INLINE unsigned char AO_char_load_acquire(const volatile unsignedchar *addr)
AO_INLINE void AO_char_store_release(volatile unsignedchar *addr, unsignedchar value)
AO_INLINE void AO_int_store_release(volatile unsigned *addr, unsigned value)
AO_INLINE unsigned short AO_short_load_acquire(const volatile unsignedshort *addr)
AO_INLINE void AO_store(volatile AO_t *addr, AO_t value)
AO_INLINE void AO_short_store(volatile unsignedshort *addr, unsignedshort value)
AO_INLINE AO_t AO_load(const volatile AO_t *addr)
AO_INLINE void AO_int_store(volatile unsigned *addr, unsigned value)
AO_INLINE unsigned char AO_char_load(const volatile unsignedchar *addr)
AO_INLINE void AO_short_store_release(volatile unsignedshort *addr, unsignedshort value)
AO_INLINE AO_t AO_load_acquire(const volatile AO_t *addr)
AO_INLINE unsigned AO_int_fetch_compare_and_swap_full(volatile unsigned *addr, unsigned old_val, unsigned new_val)