1 #ifndef _ASM_M32R_CMPXCHG_H
2 #define _ASM_M32R_CMPXCHG_H
11 #include <asm/assembler.h>
20 unsigned long tmp = 0;
30 :
"=&r" (tmp) :
"r" (x),
"r" (ptr) :
"memory");
36 :
"=&r" (tmp) :
"r" (x),
"r" (ptr) :
"memory");
42 :
"=&r" (tmp) :
"r" (x),
"r" (ptr) :
"memory");
49 "unlock %1, @%2; \n\t"
50 :
"=&r" (tmp) :
"r" (x),
"r" (ptr)
52 #ifdef CONFIG_CHIP_M32700_TS1
67 #define xchg(ptr, x) \
68 ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
71 __xchg_local(
unsigned long x,
volatile void *ptr,
int size)
74 unsigned long tmp = 0;
83 :
"=&r" (tmp) :
"r" (x),
"r" (ptr) :
"memory");
89 :
"=&r" (tmp) :
"r" (x),
"r" (ptr) :
"memory");
95 :
"=&r" (tmp) :
"r" (x),
"r" (ptr) :
"memory");
106 #define xchg_local(ptr, x) \
107 ((__typeof__(*(ptr)))__xchg_local((unsigned long)(x), (ptr), \
110 #define __HAVE_ARCH_CMPXCHG 1
112 static inline unsigned long
113 __cmpxchg_u32(
volatile unsigned int *
p,
unsigned int old,
unsigned int new)
122 " bne %0, %2, 1f; \n"
131 :
"r" (p),
"r" (old),
"r" (
new)
133 #ifdef CONFIG_CHIP_M32700_TS1
142 static inline unsigned long
143 __cmpxchg_local_u32(
volatile unsigned int *
p,
unsigned int old,
153 " bne %0, %2, 1f; \n"
162 :
"r" (p),
"r" (old),
"r" (
new)
164 #ifdef CONFIG_CHIP_M32700_TS1
177 static inline unsigned long
178 __cmpxchg(
volatile void *ptr,
unsigned long old,
unsigned long new,
int size)
182 return __cmpxchg_u32(ptr, old,
new);
192 #define cmpxchg(ptr, o, n) \
193 ((__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)(o), \
194 (unsigned long)(n), sizeof(*(ptr))))
200 unsigned long new,
int size)
204 return __cmpxchg_local_u32(ptr, old,
new);
206 return __cmpxchg_local_generic(ptr, old,
new, size);
216 #define cmpxchg_local(ptr, o, n) \
217 ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \
218 (unsigned long)(n), sizeof(*(ptr))))
219 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))