X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=arch_x86.h;h=cc3ab012c557f38db5df6c7b5c829a13ceaf511a;hp=e899684b56ddc50b9c43b506e6cb3ccdd6f254d0;hb=0114ba7f23f86623c237baeb28ec8e4b39b9bb84;hpb=3162dfe1928d4d6bf857f8e9e1c814eb8a994a0d diff --git a/arch_x86.h b/arch_x86.h index e899684..cc3ab01 100644 --- a/arch_x86.h +++ b/arch_x86.h @@ -23,6 +23,7 @@ */ #include +#include /* Assume P4 or newer */ #define CONFIG_HAVE_FENCE 1 @@ -94,56 +95,6 @@ static inline void cpu_relax(void) rep_nop(); } -#define xchg(ptr, v) \ - ((__typeof__(*(ptr)))__xchg((ptr), (unsigned long)(v), sizeof(*(ptr)))) - -struct __xchg_ptr_as_array { - unsigned long a[100]; -}; - -#define __xchg_ptr_as_array(x) ((struct __xchg_ptr_as_array *)(x)) - -/* - * xchg always implies a "lock" prefix, even on UP. See Intel documentation. - * volatile attribute is neccessary due to xchg side effect. - * *ptr is an output argument. - * x is considered local, ptr is considered remote. - */ -static inline unsigned long __xchg(volatile void *ptr, unsigned long x, - int size) -{ - switch (size) { - case 1: - asm volatile("xchgb %b0,%1" - : "=q" (x) - : "m" (*__xchg_ptr_as_array(ptr)), "0" (x) - : "memory"); - break; - case 2: - asm volatile("xchgw %w0,%1" - : "=r" (x) - : "m" (*__xchg_ptr_as_array(ptr)), "0" (x) - : "memory"); - break; - case 4: - asm volatile("xchgl %k0,%1" - : "=r" (x) - : "m" (*__xchg_ptr_as_array(ptr)), "0" (x) - : "memory"); - break; -#if (BITS_PER_LONG == 64) - case 8: - asm volatile("xchgq %0,%1" - : "=r" (x) - : "m" (*__xchg_ptr_as_array(ptr)), "0" (x) - : "memory"); - break; -#endif - } - smp_wmc(); - return x; -} - #define rdtscll(val) \ do { \ unsigned int __a, __d; \