From: Olivier Dion Date: Fri, 17 Mar 2023 21:37:51 +0000 (+0100) Subject: urcu/compiler: Use atomic builtins if configured X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=865024e9245c55286122413aaf7366dc06a00f27;p=urcu.git urcu/compiler: Use atomic builtins if configured Use __atomic_signal_fence(__ATOMIC_SEQ_CST) for cmm_barrier() if configured to use atomic builtins. Change-Id: Ib168b50f1e97a8da861b92d6882c56db230ebb2c Co-authored-by: Mathieu Desnoyers Signed-off-by: Olivier Dion Signed-off-by: Mathieu Desnoyers --- diff --git a/include/urcu/compiler.h b/include/urcu/compiler.h index 5b99407..4821129 100644 --- a/include/urcu/compiler.h +++ b/include/urcu/compiler.h @@ -15,10 +15,16 @@ # include /* for std::remove_cv */ #endif +#include + #define caa_likely(x) __builtin_expect(!!(x), 1) #define caa_unlikely(x) __builtin_expect(!!(x), 0) -#define cmm_barrier() __asm__ __volatile__ ("" : : : "memory") +#ifdef CONFIG_RCU_USE_ATOMIC_BUILTINS +# define cmm_barrier() __atomic_signal_fence(__ATOMIC_SEQ_CST) +#else +# define cmm_barrier() __asm__ __volatile__ ("" : : : "memory") +#endif /* * Instruct the compiler to perform only a single access to a variable