From e156285068a631eaafa643d9e930b31780468d00 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 8 Oct 2009 00:44:21 -0400 Subject: [PATCH] Update 386 cmpxchg support Signed-off-by: Mathieu Desnoyers --- urcu-pointer-static.h | 5 ++++- urcu/uatomic_arch_x86.h | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/urcu-pointer-static.h b/urcu-pointer-static.h index 33bfdee..c0533c9 100644 --- a/urcu-pointer-static.h +++ b/urcu-pointer-static.h @@ -78,7 +78,10 @@ if (!__builtin_constant_p(_new) || \ ((_new) != NULL)) \ wmb(); \ - uatomic_cmpxchg(p, _________pold, _________pnew); \ + (likely(URCU_CAS_AVAIL()) ? \ + (uatomic_cmpxchg(p, _________pold, _________pnew)) : \ + (compat_uatomic_cmpxchg(p, _________pold, \ + _________pnew))) \ }) /** diff --git a/urcu/uatomic_arch_x86.h b/urcu/uatomic_arch_x86.h index fccea8e..dfb5876 100644 --- a/urcu/uatomic_arch_x86.h +++ b/urcu/uatomic_arch_x86.h @@ -402,7 +402,13 @@ void _uatomic_dec(void *addr, int len) #define compat_uatomic_cmpxchg(ptr, old, _new) uatomic_cmpxchg(ptr, old, _new) #else extern int __urcu_cas_avail; -#define URCU_CAS_AVAIL() __urcu_cas_avail +extern int __urcu_cas_init(void); +#define URCU_CAS_AVAIL() \ + ((likely(__urcu_cas_avail > 0)) ? \ + (1) : \ + ((unlikely(__urcu_cas_avail < 0) ? \ + (__urcu_cas_init()) : \ + (0)))) extern unsigned long _compat_uatomic_cmpxchg(void *addr, unsigned long old, unsigned long _new, int len); -- 2.34.1