If configured to use atomic builtins, use them for implementing the
CMM_LOAD_SHARED and CMM_STORE_SHARED macros.

Change-Id: I3eaaaaf0d26c47aced6e94b40fd59c7b8baa6272
Co-authored-by: Mathieu Desnoyers <mathieu.desnoy...@efficios.com>
Signed-off-by: Olivier Dion <od...@efficios.com>
---
 include/urcu/system.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/urcu/system.h b/include/urcu/system.h
index faae390..f184aad 100644
--- a/include/urcu/system.h
+++ b/include/urcu/system.h
@@ -19,9 +19,28 @@
  * all copies or substantial portions of the Software.
  */
 
+#include <urcu/config.h>
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
 
+#ifdef CONFIG_RCU_USE_ATOMIC_BUILTINS
+
+#define CMM_LOAD_SHARED(x)                     \
+       __atomic_load_n(&(x), __ATOMIC_RELAXED)
+
+#define _CMM_LOAD_SHARED(x) CMM_LOAD_SHARED(x)
+
+#define CMM_STORE_SHARED(x, v)                                 \
+       __extension__                                           \
+       ({                                                      \
+               __typeof__(v) _v = (v);                         \
+               __atomic_store_n(&(x), _v, __ATOMIC_RELAXED);   \
+               _v;                                             \
+       })
+
+#define _CMM_STORE_SHARED(x, v) CMM_STORE_SHARED(x, v)
+
+#else
 /*
  * Identify a shared load. A cmm_smp_rmc() or cmm_smp_mc() should come
  * before the load.
@@ -56,4 +75,6 @@
                _v = _v;        /* Work around clang "unused result" */ \
        })
 
+#endif /* CONFIG_RCU_USE_ATOMIC_BUILTINS */
+
 #endif /* _URCU_SYSTEM_H */
-- 
2.39.2

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Reply via email to