diff options
Diffstat (limited to 'include/asm-x86_64/system.h')
-rw-r--r-- | include/asm-x86_64/system.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h index 213b7fe5d998..1f1c0bf4a5df 100644 --- a/include/asm-x86_64/system.h +++ b/include/asm-x86_64/system.h | |||
@@ -214,9 +214,45 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, | |||
214 | return old; | 214 | return old; |
215 | } | 215 | } |
216 | 216 | ||
217 | static inline unsigned long __cmpxchg_local(volatile void *ptr, | ||
218 | unsigned long old, unsigned long new, int size) | ||
219 | { | ||
220 | unsigned long prev; | ||
221 | switch (size) { | ||
222 | case 1: | ||
223 | __asm__ __volatile__("cmpxchgb %b1,%2" | ||
224 | : "=a"(prev) | ||
225 | : "q"(new), "m"(*__xg(ptr)), "0"(old) | ||
226 | : "memory"); | ||
227 | return prev; | ||
228 | case 2: | ||
229 | __asm__ __volatile__("cmpxchgw %w1,%2" | ||
230 | : "=a"(prev) | ||
231 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
232 | : "memory"); | ||
233 | return prev; | ||
234 | case 4: | ||
235 | __asm__ __volatile__("cmpxchgl %k1,%2" | ||
236 | : "=a"(prev) | ||
237 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
238 | : "memory"); | ||
239 | return prev; | ||
240 | case 8: | ||
241 | __asm__ __volatile__("cmpxchgq %1,%2" | ||
242 | : "=a"(prev) | ||
243 | : "r"(new), "m"(*__xg(ptr)), "0"(old) | ||
244 | : "memory"); | ||
245 | return prev; | ||
246 | } | ||
247 | return old; | ||
248 | } | ||
249 | |||
217 | #define cmpxchg(ptr,o,n)\ | 250 | #define cmpxchg(ptr,o,n)\ |
218 | ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ | 251 | ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ |
219 | (unsigned long)(n),sizeof(*(ptr)))) | 252 | (unsigned long)(n),sizeof(*(ptr)))) |
253 | #define cmpxchg_local(ptr,o,n)\ | ||
254 | ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ | ||
255 | (unsigned long)(n),sizeof(*(ptr)))) | ||
220 | 256 | ||
221 | #ifdef CONFIG_SMP | 257 | #ifdef CONFIG_SMP |
222 | #define smp_mb() mb() | 258 | #define smp_mb() mb() |