X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu%2Fuatomic_arch_x86.h;h=aed513b67b4146f8f50bf52f133de0079611d97c;hp=3bfe86d0a31f35e9a3f04a1c5079811b8971e167;hb=6cf3827cf5809fbcee555fb08286ad756be42dad;hpb=02be55611d3b1c7bf4fdfcb3a9c98f621882d417 diff --git a/urcu/uatomic_arch_x86.h b/urcu/uatomic_arch_x86.h index 3bfe86d..aed513b 100644 --- a/urcu/uatomic_arch_x86.h +++ b/urcu/uatomic_arch_x86.h @@ -23,22 +23,13 @@ #include #include +#define UATOMIC_HAS_ATOMIC_BYTE +#define UATOMIC_HAS_ATOMIC_SHORT + #ifdef __cplusplus extern "C" { #endif -#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 - /* * Derived from AO_compare_and_swap() and AO_test_and_set_full(). */ @@ -48,8 +39,7 @@ struct __uatomic_dummy { }; #define __hp(x) ((struct __uatomic_dummy *)(x)) -#define _uatomic_set(addr, v) STORE_SHARED(*(addr), (v)) -#define _uatomic_read(addr) LOAD_SHARED(*(addr)) +#define _uatomic_set(addr, v) CMM_STORE_SHARED(*(addr), (v)) /* cmpxchg */ @@ -91,7 +81,7 @@ unsigned long __uatomic_cmpxchg(void *addr, unsigned long old, : "memory"); return result; } -#if (BITS_PER_LONG == 64) +#if (CAA_BITS_PER_LONG == 64) case 8: { unsigned long result = old; @@ -153,7 +143,7 @@ unsigned long __uatomic_exchange(void *addr, unsigned long val, int len) : "memory"); return result; } -#if (BITS_PER_LONG == 64) +#if (CAA_BITS_PER_LONG == 64) case 8: { unsigned long result; @@ -176,7 +166,7 @@ unsigned long __uatomic_exchange(void *addr, unsigned long val, int len) ((__typeof__(*(addr))) __uatomic_exchange((addr), (unsigned long)(v), \ sizeof(*(addr)))) -/* uatomic_add_return, uatomic_sub_return */ +/* uatomic_add_return */ static inline __attribute__((always_inline)) unsigned long __uatomic_add_return(void *addr, unsigned long val, @@ -216,7 +206,7 @@ unsigned long __uatomic_add_return(void *addr, unsigned long val, : "memory"); return result + (unsigned int)val; } -#if (BITS_PER_LONG == 64) +#if (CAA_BITS_PER_LONG == 64) case 8: { unsigned long result = val; @@ -241,9 +231,7 @@ unsigned long __uatomic_add_return(void *addr, unsigned long val, (unsigned long)(v), \ sizeof(*(addr)))) -#define _uatomic_sub_return(addr, v) _uatomic_add_return((addr), -(v)) - -/* uatomic_add, uatomic_sub */ +/* uatomic_add */ static inline __attribute__((always_inline)) void __uatomic_add(void *addr, unsigned long val, int len) @@ -276,7 +264,7 @@ void __uatomic_add(void *addr, unsigned long val, int len) : "memory"); return; } -#if (BITS_PER_LONG == 64) +#if (CAA_BITS_PER_LONG == 64) case 8: { __asm__ __volatile__( @@ -297,8 +285,6 @@ void __uatomic_add(void *addr, unsigned long val, int len) #define _uatomic_add(addr, v) \ (__uatomic_add((addr), (unsigned long)(v), sizeof(*(addr)))) -#define _uatomic_sub(addr, v) _uatomic_add((addr), -(v)) - /* uatomic_inc */ @@ -333,7 +319,7 @@ void __uatomic_inc(void *addr, int len) : "memory"); return; } -#if (BITS_PER_LONG == 64) +#if (CAA_BITS_PER_LONG == 64) case 8: { __asm__ __volatile__( @@ -386,7 +372,7 @@ void __uatomic_dec(void *addr, int len) : "memory"); return; } -#if (BITS_PER_LONG == 64) +#if (CAA_BITS_PER_LONG == 64) case 8: { __asm__ __volatile__( @@ -406,7 +392,7 @@ void __uatomic_dec(void *addr, int len) #define _uatomic_dec(addr) (__uatomic_dec((addr), sizeof(*(addr)))) -#if ((BITS_PER_LONG != 64) && defined(CONFIG_RCU_COMPAT_ARCH)) +#if ((CAA_BITS_PER_LONG != 64) && defined(CONFIG_RCU_COMPAT_ARCH)) extern int __rcu_cas_avail; extern int __rcu_cas_init(void); @@ -449,36 +435,29 @@ extern unsigned long _compat_uatomic_xchg(void *addr, (unsigned long)(v), \ sizeof(*(addr)))) -#define compat_uatomic_sub_return(addr, v) \ - compat_uatomic_add_return((addr), -(v)) #define compat_uatomic_add(addr, v) \ ((void)compat_uatomic_add_return((addr), (v))) -#define compat_uatomic_sub(addr, v) \ - ((void)compat_uatomic_sub_return((addr), (v))) #define compat_uatomic_inc(addr) \ (compat_uatomic_add((addr), 1)) #define compat_uatomic_dec(addr) \ - (compat_uatomic_sub((addr), 1)) + (compat_uatomic_add((addr), -1)) #else #define UATOMIC_COMPAT(insn) (_uatomic_##insn) #endif /* Read is atomic even in compat mode */ -#define uatomic_read(addr) _uatomic_read(addr) - #define uatomic_set(addr, v) \ UATOMIC_COMPAT(set(addr, v)) + #define uatomic_cmpxchg(addr, old, _new) \ UATOMIC_COMPAT(cmpxchg(addr, old, _new)) #define uatomic_xchg(addr, v) \ UATOMIC_COMPAT(xchg(addr, v)) #define uatomic_add_return(addr, v) \ UATOMIC_COMPAT(add_return(addr, v)) -#define uatomic_sub_return(addr, v) \ - UATOMIC_COMPAT(sub_return(addr, v)) + #define uatomic_add(addr, v) UATOMIC_COMPAT(add(addr, v)) -#define uatomic_sub(addr, v) UATOMIC_COMPAT(sub(addr, v)) #define uatomic_inc(addr) UATOMIC_COMPAT(inc(addr)) #define uatomic_dec(addr) UATOMIC_COMPAT(dec(addr)) @@ -486,4 +465,6 @@ extern unsigned long _compat_uatomic_xchg(void *addr, } #endif +#include + #endif /* _URCU_ARCH_UATOMIC_X86_H */