summaryrefslogtreecommitdiff
path: root/include/atomic.h
diff options
context:
space:
mode:
authorDmitry Chestnykh <dm.chestnykh@gmail.com>2024-05-20 11:04:36 +0300
committerWaldemar Brodkorb <wbx@openadk.org>2024-05-20 10:07:22 +0200
commit3f6ad63609f4496160ada83efb120744446eda94 (patch)
tree0e9e7094196ca1b464c11fbcfbd67bd2b11f4baf /include/atomic.h
parentca9049c9dbfdb260e3ca0ce27a09de770f3b679b (diff)
Cast to proper types inside atomic macroses.
GCC-14 raises `-Wint-conversion` error if lvalues are of pointer types and rvalues are of integer types. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
Diffstat (limited to 'include/atomic.h')
-rw-r--r--include/atomic.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/include/atomic.h b/include/atomic.h
index 267aff5d5..3adcfbc5f 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -54,15 +54,15 @@
and following args. */
#define __atomic_val_bysize(pre, post, mem, ...) \
({ \
- __typeof (*mem) __atg1_result; \
+ __typeof ((__typeof (*(mem))) *(mem)) __atg1_result; \
if (sizeof (*mem) == 1) \
- __atg1_result = pre##_8_##post (mem, __VA_ARGS__); \
+ __atg1_result = (__typeof ((__typeof (*(mem))) *(mem))) pre##_8_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 2) \
- __atg1_result = pre##_16_##post (mem, __VA_ARGS__); \
+ __atg1_result = (__typeof ((__typeof (*(mem))) *(mem))) pre##_16_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 4) \
- __atg1_result = pre##_32_##post (mem, __VA_ARGS__); \
+ __atg1_result = (__typeof ((__typeof (*(mem))) *(mem))) pre##_32_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 8) \
- __atg1_result = pre##_64_##post (mem, __VA_ARGS__); \
+ __atg1_result = (__typeof ((__typeof (*(mem))) *(mem))) pre##_64_##post (mem, __VA_ARGS__); \
else \
abort (); \
__atg1_result; \
@@ -71,13 +71,13 @@
({ \
int __atg2_result; \
if (sizeof (*mem) == 1) \
- __atg2_result = pre##_8_##post (mem, __VA_ARGS__); \
+ __atg2_result = (int) pre##_8_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 2) \
- __atg2_result = pre##_16_##post (mem, __VA_ARGS__); \
+ __atg2_result = (int) pre##_16_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 4) \
- __atg2_result = pre##_32_##post (mem, __VA_ARGS__); \
+ __atg2_result = (int) pre##_32_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 8) \
- __atg2_result = pre##_64_##post (mem, __VA_ARGS__); \
+ __atg2_result = (int) pre##_64_##post (mem, __VA_ARGS__); \
else \
abort (); \
__atg2_result; \