]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - arch/x86/include/asm/cmpxchg_32.h
x86, asm: Merge cmpxchg_486_u64() and cmpxchg8b_emu()
[net-next-2.6.git] / arch / x86 / include / asm / cmpxchg_32.h
index f5bd1fd388ff040dca4febd8d58a4dae0d27f291..284a6e8f7ce167e8e854f47db895a44ee2cfbefa 100644 (file)
@@ -246,8 +246,6 @@ static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old,
  * to simulate the cmpxchg8b on the 80386 and 80486 CPU.
  */
 
-extern unsigned long long cmpxchg_486_u64(volatile void *, u64, u64);
-
 #define cmpxchg64(ptr, o, n)                                   \
 ({                                                             \
        __typeof__(*(ptr)) __ret;                               \
@@ -265,20 +263,20 @@ extern unsigned long long cmpxchg_486_u64(volatile void *, u64, u64);
        __ret; })
 
 
-
-#define cmpxchg64_local(ptr, o, n)                                     \
-({                                                                     \
-       __typeof__(*(ptr)) __ret;                                       \
-       if (likely(boot_cpu_data.x86 > 4))                              \
-               __ret = (__typeof__(*(ptr)))__cmpxchg64_local((ptr),    \
-                               (unsigned long long)(o),                \
-                               (unsigned long long)(n));               \
-       else                                                            \
-               __ret = (__typeof__(*(ptr)))cmpxchg_486_u64((ptr),      \
-                               (unsigned long long)(o),                \
-                               (unsigned long long)(n));               \
-       __ret;                                                          \
-})
+#define cmpxchg64_local(ptr, o, n)                             \
+({                                                             \
+       __typeof__(*(ptr)) __ret;                               \
+       __typeof__(*(ptr)) __old = (o);                         \
+       __typeof__(*(ptr)) __new = (n);                         \
+       alternative_io("call cmpxchg8b_emu",                    \
+                      "cmpxchg8b (%%esi)" ,                    \
+                      X86_FEATURE_CX8,                         \
+                      "=A" (__ret),                            \
+                      "S" ((ptr)), "0" (__old),                \
+                      "b" ((unsigned int)__new),               \
+                      "c" ((unsigned int)(__new>>32))          \
+                      : "memory");                             \
+       __ret; })
 
 #endif