aboutsummaryrefslogtreecommitdiff
path: root/sys/sys
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2021-01-25 20:09:41 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-01-25 22:40:15 +0000
commit054ce2b0371042c0dbc4b3ab1d7e7795ad75d51e (patch)
treee2c4c5fdbfff998eacf372472212afbf23bf8880 /sys/sys
parentcc96f92a570e05636a20fdd15d4616b127bb9ecc (diff)
downloadsrc-054ce2b0371042c0dbc4b3ab1d7e7795ad75d51e.tar.gz
src-054ce2b0371042c0dbc4b3ab1d7e7795ad75d51e.zip
atomic: add stub atomic_load_consume_ptr
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/_cscan_atomic.h5
-rw-r--r--sys/sys/atomic_common.h8
2 files changed, 13 insertions, 0 deletions
diff --git a/sys/sys/_cscan_atomic.h b/sys/sys/_cscan_atomic.h
index 3bd9455102b1..aed96580e1e4 100644
--- a/sys/sys/_cscan_atomic.h
+++ b/sys/sys/_cscan_atomic.h
@@ -236,6 +236,11 @@ void kcsan_atomic_thread_fence_seq_cst(void);
__retptr; \
})
#define atomic_load_acq_ptr kcsan_atomic_load_acq_ptr
+#define atomic_load_consume_ptr(x) ({ \
+ __typeof(*x) __retptr; \
+ __retptr = (void *)kcsan_atomic_load_acq_ptr((volatile uintptr_t *)(x));\
+ __retptr; \
+})
#define atomic_readandclear_ptr kcsan_atomic_readandclear_ptr
#define atomic_set_ptr kcsan_atomic_set_ptr
#define atomic_set_acq_ptr kcsan_atomic_set_acq_ptr
diff --git a/sys/sys/atomic_common.h b/sys/sys/atomic_common.h
index 4c29d132c369..48f0a8b8939c 100644
--- a/sys/sys/atomic_common.h
+++ b/sys/sys/atomic_common.h
@@ -70,4 +70,12 @@
(*(volatile uint64_t *)(p) = (uint64_t)(v))
#endif
+/*
+ * Currently all architectures provide acquire and release fences on their own,
+ * but they don't provide consume. Kludge below allows relevant code to stop
+ * openly resorting to the stronger acquire fence, to be sorted out.
+ */
+#define atomic_load_consume_ptr(p) \
+ ((__typeof(*p)) atomic_load_acq_ptr((uintptr_t *)p))
+
#endif