Go to the documentation of this file.
22 #ifndef _ASM_CMPXCHG_H
23 #define _ASM_CMPXCHG_H
36 static inline unsigned long __xchg(
unsigned long x,
volatile void *
ptr,
42 if (size != 4)
do {
asm volatile(
"brkpt;\n"); }
while (1);
45 "1: %0 = memw_locked(%1);\n"
46 " memw_locked(%1,P0) = %2;\n"
59 #define xchg(ptr, v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v), (ptr), \
67 #define __HAVE_ARCH_CMPXCHG 1
69 #define cmpxchg(ptr, old, new) \
71 __typeof__(ptr) __ptr = (ptr); \
72 __typeof__(*(ptr)) __old = (old); \
73 __typeof__(*(ptr)) __new = (new); \
74 __typeof__(*(ptr)) __oldval = 0; \
77 "1: %0 = memw_locked(%1);\n" \
78 " { P0 = cmp.eq(%0,%2);\n" \
79 " if (!P0.new) jump:nt 2f; }\n" \
80 " memw_locked(%1,p0) = %3;\n" \
81 " if (!P0) jump 1b;\n" \
84 : "r" (__ptr), "r" (__old), "r" (__new) \