31 #define as_load_rlx(_target) __atomic_load_n(_target, __ATOMIC_RELAXED)
34 #define as_load_acq(_target) __atomic_load_n(_target, __ATOMIC_ACQUIRE)
37 #define as_load_seq(_target) __atomic_load_n(_target, __ATOMIC_SEQ_CST)
47 static inline uint64_t
59 static inline uint32_t
71 static inline uint16_t
103 static inline uint64_t
109 static inline int64_t
115 static inline uint32_t
121 static inline int32_t
127 static inline uint16_t
133 static inline int16_t
139 static inline uint8_t
156 #define as_store_rlx(_target, _value) __atomic_store_n(_target, _value, __ATOMIC_RELAXED)
159 #define as_store_rls(_target, _value) __atomic_store_n(_target, _value, __ATOMIC_RELEASE)
162 #define as_store_seq(_target, _value) __atomic_store_n(_target, _value, __ATOMIC_SEQ_CST)
281 #define as_faa_rlx(_target, _value) __atomic_fetch_add(_target, _value, __ATOMIC_RELAXED)
284 #define as_faa_acq(_target, _value) __atomic_fetch_add(_target, _value, __ATOMIC_ACQUIRE)
287 #define as_faa_rls(_target, _value) __atomic_fetch_add(_target, _value, __ATOMIC_RELEASE)
290 #define as_faa_seq(_target, _value) __atomic_fetch_add(_target, _value, __ATOMIC_SEQ_CST)
294 static inline uint64_t
300 static inline int64_t
306 static inline uint32_t
312 static inline int32_t
318 static inline uint16_t
324 static inline int16_t
335 #define as_aaf_rlx(_target, _value) __atomic_add_fetch(_target, _value, __ATOMIC_RELAXED)
338 #define as_aaf_acq(_target, _value) __atomic_add_fetch(_target, _value, __ATOMIC_ACQUIRE)
341 #define as_aaf_rls(_target, _value) __atomic_add_fetch(_target, _value, __ATOMIC_RELEASE)
344 #define as_aaf_seq(_target, _value) __atomic_add_fetch(_target, _value, __ATOMIC_SEQ_CST)
348 static inline uint64_t
354 static inline int64_t
360 static inline uint32_t
366 static inline int32_t
372 static inline uint16_t
378 static inline int16_t
386 static inline uint64_t
392 static inline int64_t
398 static inline uint32_t
404 static inline int32_t
410 static inline uint16_t
416 static inline int16_t
629 #define as_fas_rlx(_target, _value) __atomic_exchange_n(_target, _value, __ATOMIC_RELAXED)
632 #define as_fas_acq(_target, _value) __atomic_exchange_n(_target, _value, __ATOMIC_ACQUIRE)
635 #define as_fas_rls(_target, _value) __atomic_exchange_n(_target, _value, __ATOMIC_RELEASE)
638 #define as_fas_seq(_target, _value) __atomic_exchange_n(_target, _value, __ATOMIC_SEQ_CST)
642 static inline uint64_t
648 static inline int64_t
654 static inline uint32_t
660 static inline int32_t
666 static inline uint16_t
672 static inline int16_t
684 #define as_cas_rlx(_target, _old_value, _new_value) __atomic_compare_exchange_n(_target, _old_value, _new_value, false, __ATOMIC_RELAXED, __ATOMIC_RELAXED)
688 #define as_cas_acq(_target, _old_value, _new_value) __atomic_compare_exchange_n(_target, _old_value, _new_value, false, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)
692 #define as_cas_rls(_target, _old_value, _new_value) __atomic_compare_exchange_n(_target, _old_value, _new_value, false, __ATOMIC_RELEASE, __ATOMIC_RELAXED)
696 #define as_cas_seq(_target, _old_value, _new_value) __atomic_compare_exchange_n(_target, _old_value, _new_value, false, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED)
703 return as_cas_rlx(target, &old_value, new_value);
709 return as_cas_rlx(target, &old_value, new_value);
715 return as_cas_rlx(target, &old_value, new_value);
721 return as_cas_rlx(target, &old_value, new_value);
727 return as_cas_rlx(target, &old_value, new_value);
733 return as_cas_rlx(target, &old_value, new_value);
739 return as_cas_rlx(target, &old_value, new_value);
745 return as_cas_rlx(target, &old_value, new_value);
753 #define as_fence_acq() __atomic_thread_fence(__ATOMIC_ACQUIRE)
756 #define as_fence_rls() __atomic_thread_fence(__ATOMIC_RELEASE)
760 #define as_fence_rlx() __atomic_thread_fence(__ATOMIC_RELAXED)
763 #define as_fence_seq() __atomic_thread_fence(__ATOMIC_SEQ_CST)
769 typedef struct as_spinlock_s {
773 #define AS_SPINLOCK_INIT { 0 }
774 #define as_spinlock_init(_s) (_s)->u32 = 0
775 #define as_spinlock_destroy(_s) ((void)_s) // no-op
782 while (s->
u32 == 1) {
798 typedef struct as_swlock_s {
802 #define AS_SWLOCK_INIT { 0 }
803 #define as_swlock_init(_s) (_s)->u32 = 0
804 #define as_swlock_destroy(_s) ((void)_s) // no-op
806 #define AS_SWLOCK_WRITER_BIT ((uint32_t)1 << 31)
807 #define AS_SWLOCK_LATCH_BIT ((uint32_t)1 << 30)
808 #define AS_SWLOCK_WRITER_MASK (AS_SWLOCK_LATCH_BIT | AS_SWLOCK_WRITER_BIT)
809 #define AS_SWLOCK_READER_MASK (UINT32_MAX ^ AS_SWLOCK_WRITER_MASK)
static void as_store_uint16_rls(uint16_t *target, uint16_t value)
static int32_t as_fas_int32(int32_t *target, int32_t value)
static uint32_t as_fas_uint32(uint32_t *target, uint32_t value)
static int64_t as_load_int64(const int64_t *target)
static uint16_t as_load_uint16_acq(const uint16_t *target)
static int64_t as_aaf_int64(int64_t *target, int64_t value)
static void as_store_int16(int16_t *target, int16_t value)
static void as_incr_int16_rls(int16_t *target)
static uint32_t as_aaf_uint32(uint32_t *target, int32_t value)
static void as_store_int32(int32_t *target, int32_t value)
static void as_decr_uint16(uint16_t *target)
static int16_t as_load_int16(const int16_t *target)
static void as_add_uint16(uint16_t *target, int16_t value)
static void as_incr_uint16_rls(uint16_t *target)
static void * as_load_ptr_acq(void *const *target)
static void as_decr_int32(int32_t *target)
static void as_store_uint8(uint8_t *target, uint8_t value)
static void as_store_ptr_rls(void **target, void *value)
#define AS_SWLOCK_WRITER_BIT
static int8_t as_load_int8_acq(const int8_t *target)
static void as_decr_uint32_rls(uint32_t *target)
static uint64_t as_aaf_uint64_rls(uint64_t *target, int64_t value)
static void as_store_int8(int8_t *target, int8_t value)
static void as_store_int32_rls(int32_t *target, int32_t value)
static int64_t as_faa_int64(int64_t *target, int64_t value)
static int8_t as_load_int8(const int8_t *target)
static void as_decr_int64(int64_t *target)
static bool as_cas_uint32(uint32_t *target, uint32_t old_value, uint32_t new_value)
static void as_incr_uint64_rls(uint64_t *target)
#define as_store_rls(_target, _value)
static bool as_cas_uint64(uint64_t *target, uint64_t old_value, uint64_t new_value)
#define as_load_rlx(_target)
static int32_t as_faa_int32(int32_t *target, int32_t value)
static void as_decr_int16(int16_t *target)
static void as_add_int16(int16_t *target, int16_t value)
static void as_decr_int16_rls(int16_t *target)
static void as_store_uint32(uint32_t *target, uint32_t value)
static int16_t as_aaf_int16(int16_t *target, int16_t value)
#define as_load_acq(_target)
static void as_store_ptr(void **target, void *value)
static void as_swlock_read_unlock(as_swlock *rw)
static void as_incr_uint32(uint32_t *target)
static void as_add_int32(int32_t *target, int32_t value)
static int64_t as_aaf_int64_rls(int64_t *target, int64_t value)
static void as_store_uint64(uint64_t *target, uint64_t value)
static uint32_t as_faa_uint32(uint32_t *target, int32_t value)
static bool as_cas_int16(int16_t *target, int16_t old_value, int16_t new_value)
static uint64_t as_faa_uint64(uint64_t *target, int64_t value)
static uint64_t as_load_uint64_acq(const uint64_t *target)
static uint32_t as_load_uint32_acq(const uint32_t *target)
#define as_fas_rlx(_target, _value)
static uint32_t as_load_uint32(const uint32_t *target)
static void as_store_int64_rls(int64_t *target, int64_t value)
static int32_t as_aaf_int32_rls(int32_t *target, int32_t value)
static void as_decr_uint16_rls(uint16_t *target)
static void as_incr_uint16(uint16_t *target)
static uint32_t as_aaf_uint32_rls(uint32_t *target, int32_t value)
static bool as_cas_int8(int8_t *target, int8_t old_value, int8_t new_value)
#define as_faa_rls(_target, _value)
static bool as_cas_uint8(uint8_t *target, uint8_t old_value, uint8_t new_value)
#define AS_SWLOCK_WRITER_MASK
static int64_t as_load_int64_acq(const int64_t *target)
static bool as_setmax_uint64(uint64_t *target, uint64_t x)
static int16_t as_load_int16_acq(const int16_t *target)
static uint64_t as_aaf_uint64(uint64_t *target, int64_t value)
static void as_add_uint64(uint64_t *target, int64_t value)
static uint64_t as_load_uint64(const uint64_t *target)
static void as_decr_uint64_rls(uint64_t *target)
static uint16_t as_fas_uint16(uint16_t *target, uint16_t value)
#define as_faa_rlx(_target, _value)
static int16_t as_fas_int16(int16_t *target, int16_t value)
static int32_t as_load_int32(const int32_t *target)
static void as_incr_int64(int64_t *target)
static void as_swlock_write_lock(as_swlock *rw)
static bool as_cas_int64(int64_t *target, int64_t old_value, int64_t new_value)
static bool as_cas_uint16(uint16_t *target, uint16_t old_value, uint16_t new_value)
static void as_spinlock_unlock(as_spinlock *s)
#define as_fas_acq(_target, _value)
static void as_add_int64(int64_t *target, int64_t value)
static uint8_t as_load_uint8_acq(const uint8_t *target)
static void as_store_uint16(uint16_t *target, uint16_t value)
static void as_swlock_write_unlock(as_swlock *rw)
static uint16_t as_aaf_uint16(uint16_t *target, int16_t value)
static int16_t as_aaf_int16_rls(int16_t *target, int16_t value)
static void as_swlock_read_lock(as_swlock *rw)
static void as_store_int16_rls(int16_t *target, int16_t value)
static uint8_t as_load_uint8(const uint8_t *target)
static uint16_t as_faa_uint16(uint16_t *target, int16_t value)
static void as_decr_int64_rls(int64_t *target)
static void as_incr_int32_rls(int32_t *target)
static void as_spinlock_lock(as_spinlock *s)
static void as_store_int64(int64_t *target, int64_t value)
static void as_decr_uint32(uint32_t *target)
#define as_cas_rlx(_target, _old_value, _new_value)
static void as_incr_int64_rls(int64_t *target)
static void as_decr_uint64(uint64_t *target)
static bool as_cas_int32(int32_t *target, int32_t old_value, int32_t new_value)
static uint64_t as_fas_uint64(uint64_t *target, uint64_t value)
static int32_t as_load_int32_acq(const int32_t *target)
static void as_decr_int32_rls(int32_t *target)
static uint16_t as_aaf_uint16_rls(uint16_t *target, int16_t value)
static int16_t as_faa_int16(int16_t *target, int16_t value)
#define as_aaf_rlx(_target, _value)
static void as_store_int8_rls(int8_t *target, int8_t value)
static bool as_setmax_uint32(uint32_t *target, uint32_t x)
#define as_store_rlx(_target, _value)
static uint16_t as_load_uint16(const uint16_t *target)
#define as_aaf_rls(_target, _value)
static void as_incr_int16(int16_t *target)
static int32_t as_aaf_int32(int32_t *target, int32_t value)
static void as_incr_uint32_rls(uint32_t *target)
static void as_store_uint64_rls(uint64_t *target, uint64_t value)
static void as_add_uint32(uint32_t *target, int32_t value)
static void as_store_uint8_rls(uint8_t *target, uint8_t value)
static void as_incr_int32(int32_t *target)
static void as_incr_uint64(uint64_t *target)
#define AS_SWLOCK_READER_MASK
static void * as_load_ptr(void *const *target)
static void as_store_uint32_rls(uint32_t *target, uint32_t value)
static int64_t as_fas_int64(int64_t *target, int64_t value)