summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMitya Selivanov <0x7fffff@guattari.ru>2022-08-31 03:25:44 +0400
committerMitya Selivanov <0x7fffff@guattari.ru>2022-08-31 03:25:44 +0400
commitd3c79c76b75bfadbac5a4f6817b03fab88e34a00 (patch)
treef28686c63e883351e346048de5e30ed439fc7593 /source
parentd98e34df99adc34da0846f20fa5f13b748943873 (diff)
downloadkit-d3c79c76b75bfadbac5a4f6817b03fab88e34a00.zip
[atomic] win32
Diffstat (limited to 'source')
-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_)) \