42 #error "atomics.h may not be included from frontend code"
45 #define INSIDE_ATOMICS_H
66 #if defined(__arm__) || defined(__arm) || defined(__aarch64__)
68 #elif defined(__i386__) || defined(__i386) || defined(__x86_64__)
70 #elif defined(__ppc__) || defined(__powerpc__) || defined(__ppc64__) || defined(__powerpc64__)
87 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
89 #elif defined(_MSC_VER)
91 #elif defined(__SUNPRO_C) && !defined(__GNUC__)
124 #define pg_compiler_barrier() pg_compiler_barrier_impl()
136 #define pg_memory_barrier() pg_memory_barrier_impl()
149 #define pg_read_barrier() pg_read_barrier_impl()
150 #define pg_write_barrier() pg_write_barrier_impl()
155 #define pg_spin_delay() pg_spin_delay_impl()
255 return pg_atomic_read_membarrier_u32_impl(ptr);
312 pg_atomic_write_membarrier_u32_impl(ptr,
val);
327 return pg_atomic_exchange_u32_impl(ptr,
newval);
378 return pg_atomic_fetch_sub_u32_impl(ptr, sub_);
392 return pg_atomic_fetch_and_u32_impl(ptr, and_);
406 return pg_atomic_fetch_or_u32_impl(ptr, or_);
420 return pg_atomic_add_fetch_u32_impl(ptr, add_);
436 return pg_atomic_sub_fetch_u32_impl(ptr, sub_);
453 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
462 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
471 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
474 return pg_atomic_read_membarrier_u64_impl(ptr);
480 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
489 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
492 pg_atomic_write_membarrier_u64_impl(ptr,
val);
498 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
501 return pg_atomic_exchange_u64_impl(ptr,
newval);
506 uint64 *expected, uint64
newval)
508 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
517 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
526 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
530 return pg_atomic_fetch_sub_u64_impl(ptr, sub_);
536 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
539 return pg_atomic_fetch_and_u64_impl(ptr, and_);
545 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
548 return pg_atomic_fetch_or_u64_impl(ptr, or_);
554 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
557 return pg_atomic_add_fetch_u64_impl(ptr, add_);
563 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
567 return pg_atomic_sub_fetch_u64_impl(ptr, sub_);
582 #ifndef PG_HAVE_ATOMIC_U64_SIMULATION
587 if (currval >= target)
593 while (currval < target)
602 #undef INSIDE_ATOMICS_H
bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
void pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr)
uint64 pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_)
void pg_atomic_init_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 val_)
uint32 pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_)
bool pg_atomic_unlocked_test_flag_impl(volatile pg_atomic_flag *ptr)
bool pg_atomic_test_set_flag_impl(volatile pg_atomic_flag *ptr)
void pg_atomic_write_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 val)
void pg_atomic_init_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 val_)
bool pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
void pg_atomic_init_flag_impl(volatile pg_atomic_flag *ptr)
static uint32 pg_atomic_fetch_and_u32(volatile pg_atomic_uint32 *ptr, uint32 and_)
static bool pg_atomic_compare_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
static void pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
static void pg_atomic_clear_flag(volatile pg_atomic_flag *ptr)
static uint32 pg_atomic_fetch_or_u32(volatile pg_atomic_uint32 *ptr, uint32 or_)
static uint32 pg_atomic_sub_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
#define pg_memory_barrier()
static uint32 pg_atomic_read_membarrier_u32(volatile pg_atomic_uint32 *ptr)
static uint32 pg_atomic_fetch_sub_u32(volatile pg_atomic_uint32 *ptr, int32 sub_)
static bool pg_atomic_compare_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
static void pg_atomic_unlocked_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
static void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
static uint64 pg_atomic_read_membarrier_u64(volatile pg_atomic_uint64 *ptr)
static uint32 pg_atomic_fetch_add_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
static uint32 pg_atomic_add_fetch_u32(volatile pg_atomic_uint32 *ptr, int32 add_)
static uint64 pg_atomic_monotonic_advance_u64(volatile pg_atomic_uint64 *ptr, uint64 target)
static uint64 pg_atomic_fetch_add_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
static bool pg_atomic_test_set_flag(volatile pg_atomic_flag *ptr)
static uint64 pg_atomic_sub_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
static bool pg_atomic_unlocked_test_flag(volatile pg_atomic_flag *ptr)
static void pg_atomic_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
static void pg_atomic_write_membarrier_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
static uint64 pg_atomic_fetch_and_u64(volatile pg_atomic_uint64 *ptr, uint64 and_)
static uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
static uint64 pg_atomic_fetch_or_u64(volatile pg_atomic_uint64 *ptr, uint64 or_)
static uint64 pg_atomic_add_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
static uint32 pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval)
static void pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
static void pg_atomic_write_membarrier_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
static uint64 pg_atomic_fetch_sub_u64(volatile pg_atomic_uint64 *ptr, int64 sub_)
static uint64 pg_atomic_exchange_u64(volatile pg_atomic_uint64 *ptr, uint64 newval)
static void pg_atomic_init_flag(volatile pg_atomic_flag *ptr)
#define AssertPointerAlignment(ptr, bndr)
#define Assert(condition)
static void pg_atomic_unlocked_write_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 val)
static uint64 pg_atomic_read_u64_impl(volatile pg_atomic_uint64 *ptr)
static void pg_atomic_write_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 val)
static uint32 pg_atomic_read_u32_impl(volatile pg_atomic_uint32 *ptr)