aboutsummaryrefslogtreecommitdiff
path: root/sys/sys
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2021-01-25 19:39:14 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-01-25 22:40:15 +0000
commitcc96f92a570e05636a20fdd15d4616b127bb9ecc (patch)
tree7906fc8dfb4bb4f84ce96c8863e0040ad08a29e6 /sys/sys
parentf40d6217f20d69427b58d82ce4e29d88bf4dfbd6 (diff)
downloadsrc-cc96f92a570e05636a20fdd15d4616b127bb9ecc.tar.gz
src-cc96f92a570e05636a20fdd15d4616b127bb9ecc.zip
atomic: make atomic_store_ptr type-aware
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/_cscan_atomic.h5
-rw-r--r--sys/sys/atomic_common.h2
2 files changed, 5 insertions, 2 deletions
diff --git a/sys/sys/_cscan_atomic.h b/sys/sys/_cscan_atomic.h
index 19c05b179940..3bd9455102b1 100644
--- a/sys/sys/_cscan_atomic.h
+++ b/sys/sys/_cscan_atomic.h
@@ -243,7 +243,10 @@ void kcsan_atomic_thread_fence_seq_cst(void);
#define atomic_subtract_ptr kcsan_atomic_subtract_ptr
#define atomic_subtract_acq_ptr kcsan_atomic_subtract_acq_ptr
#define atomic_subtract_rel_ptr kcsan_atomic_subtract_rel_ptr
-#define atomic_store_ptr kcsan_atomic_store_ptr
+#define atomic_store_ptr(x, v) ({ \
+ __typeof(*x) __value = (v); \
+ kcsan_atomic_store_ptr((volatile uintptr_t *)(x), (uintptr_t)(__value));\
+})
#define atomic_store_rel_ptr kcsan_atomic_store_rel_ptr
#define atomic_swap_ptr kcsan_atomic_swap_ptr
#define atomic_testandclear_ptr kcsan_atomic_testandclear_ptr
diff --git a/sys/sys/atomic_common.h b/sys/sys/atomic_common.h
index a3548977b940..4c29d132c369 100644
--- a/sys/sys/atomic_common.h
+++ b/sys/sys/atomic_common.h
@@ -58,7 +58,7 @@
#define atomic_store_long(p, v) \
(*(volatile u_long *)(p) = (u_long)(v))
#define atomic_store_ptr(p, v) \
- (*(volatile uintptr_t *)(p) = (uintptr_t)(v))
+ (*(volatile __typeof(*p) *)(p) = (v))
#define atomic_store_8(p, v) \
(*(volatile uint8_t *)(p) = (uint8_t)(v))
#define atomic_store_16(p, v) \