16 #ifndef INSIDE_ATOMICS_H
17 # error "should be included via atomics.h"
24 #if !defined(pg_read_barrier_impl)
25 # define pg_read_barrier_impl pg_memory_barrier_impl
27 #if !defined(pg_write_barrier_impl)
28 # define pg_write_barrier_impl pg_memory_barrier_impl
31 #ifndef PG_HAVE_SPIN_DELAY
32 #define PG_HAVE_SPIN_DELAY
33 #define pg_spin_delay_impl() ((void)0)
38 #if !defined(PG_HAVE_ATOMIC_FLAG_SUPPORT) && defined(PG_HAVE_ATOMIC_U32_SUPPORT)
39 #define PG_HAVE_ATOMIC_FLAG_SUPPORT
43 #ifndef PG_HAVE_ATOMIC_READ_U32
44 #define PG_HAVE_ATOMIC_READ_U32
52 #ifndef PG_HAVE_ATOMIC_WRITE_U32
53 #define PG_HAVE_ATOMIC_WRITE_U32
61 #ifndef PG_HAVE_ATOMIC_UNLOCKED_WRITE_U32
62 #define PG_HAVE_ATOMIC_UNLOCKED_WRITE_U32
73 #if !defined(PG_HAVE_ATOMIC_TEST_SET_FLAG) && defined(PG_HAVE_ATOMIC_EXCHANGE_U32)
75 #define PG_HAVE_ATOMIC_INIT_FLAG
77 pg_atomic_init_flag_impl(
volatile pg_atomic_flag *ptr)
82 #define PG_HAVE_ATOMIC_TEST_SET_FLAG
84 pg_atomic_test_set_flag_impl(
volatile pg_atomic_flag *ptr)
89 #define PG_HAVE_ATOMIC_UNLOCKED_TEST_FLAG
91 pg_atomic_unlocked_test_flag_impl(
volatile pg_atomic_flag *ptr)
97 #define PG_HAVE_ATOMIC_CLEAR_FLAG
99 pg_atomic_clear_flag_impl(
volatile pg_atomic_flag *ptr)
110 #elif !defined(PG_HAVE_ATOMIC_TEST_SET_FLAG) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32)
112 #define PG_HAVE_ATOMIC_INIT_FLAG
114 pg_atomic_init_flag_impl(
volatile pg_atomic_flag *ptr)
119 #define PG_HAVE_ATOMIC_TEST_SET_FLAG
121 pg_atomic_test_set_flag_impl(
volatile pg_atomic_flag *ptr)
127 #define PG_HAVE_ATOMIC_UNLOCKED_TEST_FLAG
129 pg_atomic_unlocked_test_flag_impl(
volatile pg_atomic_flag *ptr)
134 #define PG_HAVE_ATOMIC_CLEAR_FLAG
136 pg_atomic_clear_flag_impl(
volatile pg_atomic_flag *ptr)
143 #elif !defined(PG_HAVE_ATOMIC_TEST_SET_FLAG)
144 # error "No pg_atomic_test_and_set provided"
148 #ifndef PG_HAVE_ATOMIC_INIT_U32
149 #define PG_HAVE_ATOMIC_INIT_U32
157 #if !defined(PG_HAVE_ATOMIC_EXCHANGE_U32) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32)
158 #define PG_HAVE_ATOMIC_EXCHANGE_U32
170 #if !defined(PG_HAVE_ATOMIC_FETCH_ADD_U32) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32)
171 #define PG_HAVE_ATOMIC_FETCH_ADD_U32
183 #if !defined(PG_HAVE_ATOMIC_FETCH_SUB_U32) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32)
184 #define PG_HAVE_ATOMIC_FETCH_SUB_U32
192 #if !defined(PG_HAVE_ATOMIC_FETCH_AND_U32) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32)
193 #define PG_HAVE_ATOMIC_FETCH_AND_U32
205 #if !defined(PG_HAVE_ATOMIC_FETCH_OR_U32) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32)
206 #define PG_HAVE_ATOMIC_FETCH_OR_U32
218 #if !defined(PG_HAVE_ATOMIC_ADD_FETCH_U32) && defined(PG_HAVE_ATOMIC_FETCH_ADD_U32)
219 #define PG_HAVE_ATOMIC_ADD_FETCH_U32
227 #if !defined(PG_HAVE_ATOMIC_SUB_FETCH_U32) && defined(PG_HAVE_ATOMIC_FETCH_SUB_U32)
228 #define PG_HAVE_ATOMIC_SUB_FETCH_U32
232 return pg_atomic_fetch_sub_u32_impl(ptr, sub_) - sub_;
236 #if !defined(PG_HAVE_ATOMIC_READ_MEMBARRIER_U32) && defined(PG_HAVE_ATOMIC_FETCH_ADD_U32)
237 #define PG_HAVE_ATOMIC_READ_MEMBARRIER_U32
245 #if !defined(PG_HAVE_ATOMIC_WRITE_MEMBARRIER_U32) && defined(PG_HAVE_ATOMIC_EXCHANGE_U32)
246 #define PG_HAVE_ATOMIC_WRITE_MEMBARRIER_U32
254 #if !defined(PG_HAVE_ATOMIC_EXCHANGE_U64) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64)
255 #define PG_HAVE_ATOMIC_EXCHANGE_U64
267 #ifndef PG_HAVE_ATOMIC_WRITE_U64
268 #define PG_HAVE_ATOMIC_WRITE_U64
270 #if defined(PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY) && \
271 !defined(PG_HAVE_ATOMIC_U64_SIMULATION)
294 pg_atomic_exchange_u64_impl(ptr,
val);
300 #ifndef PG_HAVE_ATOMIC_READ_U64
301 #define PG_HAVE_ATOMIC_READ_U64
303 #if defined(PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY) && \
304 !defined(PG_HAVE_ATOMIC_U64_SIMULATION)
336 #ifndef PG_HAVE_ATOMIC_INIT_U64
337 #define PG_HAVE_ATOMIC_INIT_U64
345 #if !defined(PG_HAVE_ATOMIC_FETCH_ADD_U64) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64)
346 #define PG_HAVE_ATOMIC_FETCH_ADD_U64
358 #if !defined(PG_HAVE_ATOMIC_FETCH_SUB_U64) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64)
359 #define PG_HAVE_ATOMIC_FETCH_SUB_U64
367 #if !defined(PG_HAVE_ATOMIC_FETCH_AND_U64) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64)
368 #define PG_HAVE_ATOMIC_FETCH_AND_U64
380 #if !defined(PG_HAVE_ATOMIC_FETCH_OR_U64) && defined(PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64)
381 #define PG_HAVE_ATOMIC_FETCH_OR_U64
393 #if !defined(PG_HAVE_ATOMIC_ADD_FETCH_U64) && defined(PG_HAVE_ATOMIC_FETCH_ADD_U64)
394 #define PG_HAVE_ATOMIC_ADD_FETCH_U64
402 #if !defined(PG_HAVE_ATOMIC_SUB_FETCH_U64) && defined(PG_HAVE_ATOMIC_FETCH_SUB_U64)
403 #define PG_HAVE_ATOMIC_SUB_FETCH_U64
407 return pg_atomic_fetch_sub_u64_impl(ptr, sub_) - sub_;
411 #if !defined(PG_HAVE_ATOMIC_READ_MEMBARRIER_U64) && defined(PG_HAVE_ATOMIC_FETCH_ADD_U64)
412 #define PG_HAVE_ATOMIC_READ_MEMBARRIER_U64
420 #if !defined(PG_HAVE_ATOMIC_WRITE_MEMBARRIER_U64) && defined(PG_HAVE_ATOMIC_EXCHANGE_U64)
421 #define PG_HAVE_ATOMIC_WRITE_MEMBARRIER_U64
425 (void) pg_atomic_exchange_u64_impl(ptr,
val);
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_)
bool pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
#define AssertPointerAlignment(ptr, bndr)
#define pg_memory_barrier_impl()
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_init_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 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_)