diff --git a/include/common/config.h b/include/common/config.h index acd6b202b..47ff18c03 100644 --- a/include/common/config.h +++ b/include/common/config.h @@ -47,10 +47,18 @@ #define THREAD_LOCAL #endif +/* Some architectures have a double-word CAS, sometimes even dual-8 bytes */ +#if defined(__x86_64__) || defined (__aarch64__) +#define HA_HAVE_CAS_DW +#define HA_CAS_IS_8B +#elif defined(__arm__) && (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__)) +#define HA_HAVE_CAS_DW +#endif + /* On architectures supporting threads and double-word CAS, we can implement * lock-less memory pools. This isn't supported for debugging modes however. */ -#if !defined(DEBUG_NO_LOCKLESS_POOLS) && defined(USE_THREAD) && defined(HA_HAVE_CAS_DW) && !defined(DEBUG_UAF) +#if defined(USE_THREAD) && defined(HA_HAVE_CAS_DW) && !defined(DEBUG_NO_LOCKLESS_POOLS) && !defined(DEBUG_UAF) #define CONFIG_HAP_LOCKLESS_POOLS #endif diff --git a/include/common/hathreads.h b/include/common/hathreads.h index 01b218165..1f3fe8dd6 100644 --- a/include/common/hathreads.h +++ b/include/common/hathreads.h @@ -816,8 +816,7 @@ static inline void __spin_unlock(enum lock_label lbl, struct ha_spinlock *l, #endif /* DEBUG_THREAD */ #ifdef __x86_64__ -#define HA_HAVE_CAS_DW 1 -#define HA_CAS_IS_8B + static __inline int __ha_cas_dw(void *target, void *compare, const void *set) { @@ -855,7 +854,7 @@ __ha_barrier_full(void) } #elif defined(__arm__) && (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__)) -#define HA_HAVE_CAS_DW 1 + static __inline void __ha_barrier_load(void) { @@ -896,8 +895,6 @@ static __inline int __ha_cas_dw(void *target, void *compare, const void *set) } #elif defined (__aarch64__) -#define HA_HAVE_CAS_DW 1 -#define HA_CAS_IS_8B static __inline void __ha_barrier_load(void)