summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/kit/atomic.h56
1 files changed, 26 insertions, 30 deletions
diff --git a/source/kit/atomic.h b/source/kit/atomic.h
index 012d48d..23962a2 100644
--- a/source/kit/atomic.h
+++ b/source/kit/atomic.h
@@ -81,33 +81,31 @@ uint64_t kit_atomic_fetch_add_explicit_64(uint64_t volatile *var,
uint64_t value,
int memory_order);
-# define atomic_store_explicit(var_, value_, memory_order_) \
- do { \
- static_assert(sizeof *(var_) == 1 || sizeof *(var_) == 2 || \
- sizeof *(var_) == 4 || sizeof *(var_) == 8, \
- "Wrong atomic variable type"); \
- if (sizeof *(var_) == 1) \
- kit_atomic_store_explicit_8((uint8_t volatile *) (var_), \
- (uint8_t) (value_), \
- (memory_order_)); \
- if (sizeof *(var_) == 2) \
- kit_atomic_store_explicit_16((uint16_t volatile *) (var_), \
- (uint16_t) (value_), \
- (memory_order_)); \
- if (sizeof *(var_) == 4) \
- kit_atomic_store_explicit_32((uint32_t volatile *) (var_), \
- (uint32_t) (value_), \
- (memory_order_)); \
- if (sizeof *(var_) == 8) \
- kit_atomic_store_explicit_64((uint64_t volatile *) (var_), \
- (uint64_t) (value_), \
- (memory_order_)); \
+# define atomic_store_explicit(var_, value_, memory_order_) \
+ do { \
+ assert(sizeof *(var_) == 1 || sizeof *(var_) == 2 || \
+ sizeof *(var_) == 4 || sizeof *(var_) == 8); \
+ if (sizeof *(var_) == 1) \
+ kit_atomic_store_explicit_8((uint8_t volatile *) (var_), \
+ (uint8_t) (value_), \
+ (memory_order_)); \
+ if (sizeof *(var_) == 2) \
+ kit_atomic_store_explicit_16((uint16_t volatile *) (var_), \
+ (uint16_t) (value_), \
+ (memory_order_)); \
+ if (sizeof *(var_) == 4) \
+ kit_atomic_store_explicit_32((uint32_t volatile *) (var_), \
+ (uint32_t) (value_), \
+ (memory_order_)); \
+ if (sizeof *(var_) == 8) \
+ kit_atomic_store_explicit_64((uint64_t volatile *) (var_), \
+ (uint64_t) (value_), \
+ (memory_order_)); \
} while (0)
# define atomic_load_explicit(var_, memory_order_) \
- (static_assert(sizeof *(var_) == 1 || sizeof *(var_) == 2 || \
- sizeof *(var_) == 4 || sizeof *(var_) == 8, \
- "Wrong atomic variable type"), \
+ (assert(sizeof *(var_) == 1 || sizeof *(var_) == 2 || \
+ sizeof *(var_) == 4 || sizeof *(var_) == 8), \
(sizeof *(var_) == 1 \
? kit_atomic_load_explicit_8((uint8_t volatile *) (var_), \
(memory_order_)) \
@@ -121,9 +119,8 @@ uint64_t kit_atomic_fetch_add_explicit_64(uint64_t volatile *var,
(uint64_t volatile *) (var_), (memory_order_))))
# define atomic_exchange_explicit(var_, value_, memory_order_) \
- (static_assert(sizeof *(var_) == 1 || sizeof *(var_) == 2 || \
- sizeof *(var_) == 4 || sizeof *(var_) == 8, \
- "Wrong atomic variable type"), \
+ (assert(sizeof *(var_) == 1 || sizeof *(var_) == 2 || \
+ sizeof *(var_) == 4 || sizeof *(var_) == 8), \
(sizeof *(var_) == 1 ? kit_atomic_exchange_explicit_8( \
(uint8_t volatile *) (var_), \
(uint8_t) (value_), (memory_order_)) \
@@ -140,9 +137,8 @@ uint64_t kit_atomic_fetch_add_explicit_64(uint64_t volatile *var,
(memory_order_))))
# define atomic_fetch_add_explicit(var_, value_, memory_order_) \
- (static_assert(sizeof *(var_) == 1 || sizeof *(var_) == 2 || \
- sizeof *(var_) == 4 || sizeof *(var_) == 8, \
- "Wrong atomic variable type"), \
+ (assert(sizeof *(var_) == 1 || sizeof *(var_) == 2 || \
+ sizeof *(var_) == 4 || sizeof *(var_) == 8), \
(sizeof *(var_) == 1 ? kit_atomic_fetch_add_explicit_8( \
(uint8_t volatile *) (var_), \
(uint8_t) (value_), (memory_order_)) \