#if !defined(AO_ATOMIC_OPS_H) || defined(AO_ATOMIC_OPS_INCLUDED)
# error This file should not be included directly.
#endif
#if (AO_GNUC_PREREQ(12, 0) || AO_CLANG_PREREQ(13, 0)) \
&& !defined(AO_DISABLE_GCC_ATOMICS)
# include "generic.h"
#else
#include "../all_atomic_load_store.h"
#include "../ordered_except_wr.h"
#include "../test_and_set_t_is_char.h"
AO_INLINE AO_TS_VAL_t
AO_test_and_set_full(volatile AO_TS_t *addr) {
AO_TS_VAL_t oldval;
__asm__ __volatile__("ldstub %1,%0"
: "=r"(oldval), "=m"(*addr)
: "m"(*addr) : "memory");
return oldval;
}
#define AO_HAVE_test_and_set_full
#ifndef AO_NO_SPARC_V9
# ifndef AO_GENERALIZE_ASM_BOOL_CAS
AO_INLINE int
AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val) {
__asm__ __volatile__ ("membar #StoreLoad | #LoadLoad\n\t"
# if defined(__arch64__)
"casx [%1],%2,%0\n\t"
# else
"cas [%1],%2,%0\n\t"
# endif
"membar #StoreLoad | #StoreStore\n\t"
: "+r" (new_val)
: "r" (addr), "r" (old)
: "memory");
return new_val == old;
}
# define AO_HAVE_compare_and_swap_full
# endif
AO_INLINE AO_t
AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val) {
__asm__ __volatile__ ("membar #StoreLoad | #LoadLoad\n\t"
# if defined(__arch64__)
"casx [%1],%2,%0\n\t"
# else
"cas [%1],%2,%0\n\t"
# endif
"membar #StoreLoad | #StoreStore\n\t"
: "+r" (new_val)
: "r" (addr), "r" (old)
: "memory");
return new_val;
}
#define AO_HAVE_fetch_compare_and_swap_full
#endif
#endif