uatomic: update atomic set/read, use STORE_SHARED/LOAD_SHARED
[urcu.git] / urcu / uatomic_arch_x86.h
index 43de9e6be5543bb90811f373007b0fa88b6f1af6..39ec407e58c0612458ffc82209e20fc711dec0fd 100644 (file)
 
 #include <urcu/compiler.h>
 
+#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
@@ -397,4 +405,26 @@ void _uatomic_dec(void *addr, int len)
 
 #define uatomic_dec(addr)      (_uatomic_dec((addr), sizeof(*(addr))))
 
+#if (BITS_PER_LONG == 64)
+#define URCU_CAS_AVAIL()       1
+#define compat_uatomic_cmpxchg(ptr, old, _new) uatomic_cmpxchg(ptr, old, _new)
+#else
+extern int __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);
+
+#define compat_uatomic_cmpxchg(addr, old, _new)                                     \
+       ((__typeof__(*(addr))) _uatomic_cmpxchg((addr), (unsigned long)(old),\
+                                               (unsigned long)(_new),       \
+                                               sizeof(*(addr))))
+#endif
+
 #endif /* _URCU_ARCH_UATOMIC_X86_H */
This page took 0.022933 seconds and 4 git commands to generate.