]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use atomics for CMM_{LOAD,STORE}_SHARED with ThreadSanitizer
authorOndřej Surý <ondrej@isc.org>
Wed, 26 Nov 2025 16:10:37 +0000 (17:10 +0100)
committerOndřej Surý (GitLab job 6542914) <ondrej@isc.org>
Thu, 27 Nov 2025 09:32:36 +0000 (09:32 +0000)
Upstream has removed the atomics implementation of CMM_LOAD_SHARED and
CMM_STORE_SHARED as these can be used also with non-stdatomics types.
As we only use the CMM api with stdatomics types, we can restore the
previous behaviour to prevent ThreadSanitizer warnings.

(cherry picked from commit 539be61b680572beb555e10f36e0b2c16caade50)

lib/isc/include/isc/urcu.h

index cf62934632be1d50d35c8fac30f13f955f38ac71..6747dcc6d7255c66abb3200f15f78af6f16a6de1 100644 (file)
 
 #endif /* !defined(caa_container_of_check_null) */
 /* clang-format on */
+
+#ifdef __SANITIZE_THREAD__
+
+/*
+ * Restore the behaviour removed in
+ * https://github.com/urcu/userspace-rcu/commit/5cd787d0f953182a23d340669b20b150fd50c18c
+ * as we only use CMM_LOAD_SHARED() and CMM_STORE_SHARED() with atomic types.
+ */
+
+#undef CMM_LOAD_SHARED
+#define CMM_LOAD_SHARED(x) \
+       __atomic_load_n(cmm_cast_volatile(&(x)), __ATOMIC_RELAXED)
+
+#undef _CMM_LOAD_SHARED
+#define _CMM_LOAD_SHARED(x) CMM_LOAD_SHARED(x)
+
+#undef CMM_STORE_SHARED
+#define CMM_STORE_SHARED(x, v)                                \
+       __extension__({                                       \
+               __typeof__(v) _v = (v);                       \
+               __atomic_store_n(cmm_cast_volatile(&(x)), _v, \
+                                __ATOMIC_RELAXED);           \
+               _v;                                           \
+       })
+
+#undef _CMM_STORE_SHARED
+#define _CMM_STORE_SHARED(x, v) CMM_STORE_SHARED(x, v)
+
+#endif