[CPUFREQ] powernow-k8: ignore out-of-range PstateStatus value
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / x86 / kernel / cpu / cmpxchg.c
blob2056ccf572ccac780978100ff28836d9d52d8296
1 /*
2 * cmpxchg*() fallbacks for CPU not supporting these instructions
3 */
5 #include <linux/kernel.h>
6 #include <linux/smp.h>
7 #include <linux/module.h>
9 #ifndef CONFIG_X86_CMPXCHG
10 unsigned long cmpxchg_386_u8(volatile void *ptr, u8 old, u8 new)
12 u8 prev;
13 unsigned long flags;
15 /* Poor man's cmpxchg for 386. Unsuitable for SMP */
16 local_irq_save(flags);
17 prev = *(u8 *)ptr;
18 if (prev == old)
19 *(u8 *)ptr = new;
20 local_irq_restore(flags);
21 return prev;
23 EXPORT_SYMBOL(cmpxchg_386_u8);
25 unsigned long cmpxchg_386_u16(volatile void *ptr, u16 old, u16 new)
27 u16 prev;
28 unsigned long flags;
30 /* Poor man's cmpxchg for 386. Unsuitable for SMP */
31 local_irq_save(flags);
32 prev = *(u16 *)ptr;
33 if (prev == old)
34 *(u16 *)ptr = new;
35 local_irq_restore(flags);
36 return prev;
38 EXPORT_SYMBOL(cmpxchg_386_u16);
40 unsigned long cmpxchg_386_u32(volatile void *ptr, u32 old, u32 new)
42 u32 prev;
43 unsigned long flags;
45 /* Poor man's cmpxchg for 386. Unsuitable for SMP */
46 local_irq_save(flags);
47 prev = *(u32 *)ptr;
48 if (prev == old)
49 *(u32 *)ptr = new;
50 local_irq_restore(flags);
51 return prev;
53 EXPORT_SYMBOL(cmpxchg_386_u32);
54 #endif
56 #ifndef CONFIG_X86_CMPXCHG64
57 unsigned long long cmpxchg_486_u64(volatile void *ptr, u64 old, u64 new)
59 u64 prev;
60 unsigned long flags;
62 /* Poor man's cmpxchg8b for 386 and 486. Unsuitable for SMP */
63 local_irq_save(flags);
64 prev = *(u64 *)ptr;
65 if (prev == old)
66 *(u64 *)ptr = new;
67 local_irq_restore(flags);
68 return prev;
70 EXPORT_SYMBOL(cmpxchg_486_u64);
71 #endif