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__)
98#if !defined(PG_HAVE_ATOMIC_U32_SUPPORT)
99#error "could not find an implementation of pg_atomic_uint32"
101#if !defined(pg_compiler_barrier_impl)
102#error "could not find an implementation of pg_compiler_barrier"
104#if !defined(pg_memory_barrier_impl)
105#error "could not find an implementation of pg_memory_barrier_impl"
131#define pg_compiler_barrier() pg_compiler_barrier_impl()
143#define pg_memory_barrier() pg_memory_barrier_impl()
156#define pg_read_barrier() pg_read_barrier_impl()
157#define pg_write_barrier() pg_write_barrier_impl()
162#define pg_spin_delay() pg_spin_delay_impl()
172 pg_atomic_init_flag_impl(ptr);
185 return pg_atomic_test_set_flag_impl(ptr);
198 return pg_atomic_unlocked_test_flag_impl(ptr);
209 pg_atomic_clear_flag_impl(ptr);
262 return pg_atomic_read_membarrier_u32_impl(ptr);
319 pg_atomic_write_membarrier_u32_impl(ptr,
val);
385 return pg_atomic_fetch_sub_u32_impl(ptr, sub_);
399 return pg_atomic_fetch_and_u32_impl(ptr, and_);
413 return pg_atomic_fetch_or_u32_impl(ptr, or_);
427 return pg_atomic_add_fetch_u32_impl(ptr, add_);
443 return pg_atomic_sub_fetch_u32_impl(ptr, sub_);
460#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
469#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
478#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
481 return pg_atomic_read_membarrier_u64_impl(ptr);
487#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
496#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
499 pg_atomic_write_membarrier_u64_impl(ptr,
val);
505#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
508 return pg_atomic_exchange_u64_impl(ptr,
newval);
515#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
524#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
533#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
537 return pg_atomic_fetch_sub_u64_impl(ptr, sub_);
543#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
546 return pg_atomic_fetch_and_u64_impl(ptr, and_);
552#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
555 return pg_atomic_fetch_or_u64_impl(ptr, or_);
561#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
564 return pg_atomic_add_fetch_u64_impl(ptr, add_);
570#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
574 return pg_atomic_sub_fetch_u64_impl(ptr, sub_);
589#ifndef PG_HAVE_ATOMIC_U64_SIMULATION
594 if (currval >= target)
600 while (currval < target)
609#undef INSIDE_ATOMICS_H
static bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
static uint32 pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_)
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_)
bool pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
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)
static uint32 pg_atomic_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 newval)
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_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 val)
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)
static void pg_atomic_init_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 val_)
Assert(PointerIsAligned(start, uint64))