diff options
Diffstat (limited to 'include/asm-i386/system.h')
-rw-r--r-- | include/asm-i386/system.h | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h index 97d52ac49e46..772f85da1206 100644 --- a/include/asm-i386/system.h +++ b/include/asm-i386/system.h | |||
@@ -263,6 +263,10 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz | |||
263 | 263 | ||
264 | #ifdef CONFIG_X86_CMPXCHG | 264 | #ifdef CONFIG_X86_CMPXCHG |
265 | #define __HAVE_ARCH_CMPXCHG 1 | 265 | #define __HAVE_ARCH_CMPXCHG 1 |
266 | #define cmpxchg(ptr,o,n)\ | ||
267 | ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ | ||
268 | (unsigned long)(n),sizeof(*(ptr)))) | ||
269 | #endif | ||
266 | 270 | ||
267 | static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, | 271 | static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, |
268 | unsigned long new, int size) | 272 | unsigned long new, int size) |
@@ -291,10 +295,42 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, | |||
291 | return old; | 295 | return old; |
292 | } | 296 | } |
293 | 297 | ||
294 | #define cmpxchg(ptr,o,n)\ | 298 | #ifndef CONFIG_X86_CMPXCHG |
295 | ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ | 299 | /* |
296 | (unsigned long)(n),sizeof(*(ptr)))) | 300 | * Building a kernel capable running on 80386. It may be necessary to |
301 | * simulate the cmpxchg on the 80386 CPU. For that purpose we define | ||
302 | * a function for each of the sizes we support. | ||
303 | */ | ||
297 | 304 | ||
305 | extern unsigned long cmpxchg_386_u8(volatile void *, u8, u8); | ||
306 | extern unsigned long cmpxchg_386_u16(volatile void *, u16, u16); | ||
307 | extern unsigned long cmpxchg_386_u32(volatile void *, u32, u32); | ||
308 | |||
309 | static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old, | ||
310 | unsigned long new, int size) | ||
311 | { | ||
312 | switch (size) { | ||
313 | case 1: | ||
314 | return cmpxchg_386_u8(ptr, old, new); | ||
315 | case 2: | ||
316 | return cmpxchg_386_u16(ptr, old, new); | ||
317 | case 4: | ||
318 | return cmpxchg_386_u32(ptr, old, new); | ||
319 | } | ||
320 | return old; | ||
321 | } | ||
322 | |||
323 | #define cmpxchg(ptr,o,n) \ | ||
324 | ({ \ | ||
325 | __typeof__(*(ptr)) __ret; \ | ||
326 | if (likely(boot_cpu_data.x86 > 3)) \ | ||
327 | __ret = __cmpxchg((ptr), (unsigned long)(o), \ | ||
328 | (unsigned long)(n), sizeof(*(ptr))); \ | ||
329 | else \ | ||
330 | __ret = cmpxchg_386((ptr), (unsigned long)(o), \ | ||
331 | (unsigned long)(n), sizeof(*(ptr))); \ | ||
332 | __ret; \ | ||
333 | }) | ||
298 | #endif | 334 | #endif |
299 | 335 | ||
300 | #ifdef CONFIG_X86_CMPXCHG64 | 336 | #ifdef CONFIG_X86_CMPXCHG64 |