X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=urcu%2Fuatomic_arch_x86.h;h=39ec407e58c0612458ffc82209e20fc711dec0fd;hb=618c4ae180e1d9406bcad808cd0cb88addc992a1;hp=fccea8e2d350321ebe9cbf4517a68866e4b5fa19;hpb=7d413817f09b2d17b1a79ea012590609ffab5eb6;p=urcu.git diff --git a/urcu/uatomic_arch_x86.h b/urcu/uatomic_arch_x86.h index fccea8e..39ec407 100644 --- a/urcu/uatomic_arch_x86.h +++ b/urcu/uatomic_arch_x86.h @@ -22,6 +22,14 @@ #include +#ifndef __SIZEOF_LONG__ +#if defined(__x86_64__) || defined(__amd64__) +#define __SIZEOF_LONG__ 8 +#else +#define __SIZEOF_LONG__ 4 +#endif +#endif + #ifndef BITS_PER_LONG #define BITS_PER_LONG (__SIZEOF_LONG__ * 8) #endif @@ -402,7 +410,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);