[PATCH 17/18] x86: add local and sync variants of xadd

From: Jeremy Fitzhardinge
Date: Wed Aug 24 2011 - 13:54:26 EST


From: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
arch/x86/include/asm/cmpxchg.h | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
index c99ce79..992ac80 100644
--- a/arch/x86/include/asm/cmpxchg.h
+++ b/arch/x86/include/asm/cmpxchg.h
@@ -193,26 +193,26 @@ extern void __xadd_wrong_size(void);
__cmpxchg_local_flag((ptr), (old), (new), sizeof(*ptr))
#endif

-#define xadd(ptr, inc) \
+#define __xadd(ptr, inc, lock) \
do { \
switch (sizeof(*(ptr))) { \
case __X86_CASE_B: \
- asm volatile (LOCK_PREFIX "xaddb %b0, %1\n" \
+ asm volatile (lock "xaddb %b0, %1\n" \
: "+r" (inc), "+m" (*(ptr)) \
: : "memory", "cc"); \
break; \
case __X86_CASE_W: \
- asm volatile (LOCK_PREFIX "xaddw %w0, %1\n" \
+ asm volatile (lock "xaddw %w0, %1\n" \
: "+r" (inc), "+m" (*(ptr)) \
: : "memory", "cc"); \
break; \
case __X86_CASE_L: \
- asm volatile (LOCK_PREFIX "xaddl %0, %1\n" \
+ asm volatile (lock "xaddl %0, %1\n" \
: "+r" (inc), "+m" (*(ptr)) \
: : "memory", "cc"); \
break; \
case __X86_CASE_Q: \
- asm volatile (LOCK_PREFIX "xaddq %q0, %1\n" \
+ asm volatile (lock "xaddq %q0, %1\n" \
: "+r" (inc), "+m" (*(ptr)) \
: : "memory", "cc"); \
break; \
@@ -221,4 +221,8 @@ extern void __xadd_wrong_size(void);
} \
} while(0)

+#define xadd(ptr, inc) __xadd((ptr), (inc), LOCK_PREFIX)
+#define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
+#define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
+
#endif /* ASM_X86_CMPXCHG_H */
--
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/