diff options
author | Nick Piggin <nickpiggin@yahoo.com.au> | 2005-11-13 19:07:23 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-13 21:14:15 -0500 |
commit | 53e86b91b7ae66d4c2757195cbd42e00d9199cf2 (patch) | |
tree | 80c44aeb046ac91a5bc7465da91a7b2519c53096 /arch/i386 | |
parent | dbdf65b1b7f8ec48bda1604cfea7ac09ce583d6b (diff) |
[PATCH] i386: generic cmpxchg
- Make cmpxchg generally available on the i386 platform.
- Provide emulation of cmpxchg suitable for uniprocessor if built and run on
386.
From: Christoph Lameter <clameter@sgi.com>
- Cut down patch and small style changes.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/i386')
-rw-r--r-- | arch/i386/kernel/cpu/intel.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c index 43601de0f633..c28d26fb5f24 100644 --- a/arch/i386/kernel/cpu/intel.c +++ b/arch/i386/kernel/cpu/intel.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/bitops.h> | 6 | #include <linux/bitops.h> |
7 | #include <linux/smp.h> | 7 | #include <linux/smp.h> |
8 | #include <linux/thread_info.h> | 8 | #include <linux/thread_info.h> |
9 | #include <linux/module.h> | ||
9 | 10 | ||
10 | #include <asm/processor.h> | 11 | #include <asm/processor.h> |
11 | #include <asm/msr.h> | 12 | #include <asm/msr.h> |
@@ -264,5 +265,52 @@ __init int intel_cpu_init(void) | |||
264 | return 0; | 265 | return 0; |
265 | } | 266 | } |
266 | 267 | ||
268 | #ifndef CONFIG_X86_CMPXCHG | ||
269 | unsigned long cmpxchg_386_u8(volatile void *ptr, u8 old, u8 new) | ||
270 | { | ||
271 | u8 prev; | ||
272 | unsigned long flags; | ||
273 | |||
274 | /* Poor man's cmpxchg for 386. Unsuitable for SMP */ | ||
275 | local_irq_save(flags); | ||
276 | prev = *(u8 *)ptr; | ||
277 | if (prev == old) | ||
278 | *(u8 *)ptr = new; | ||
279 | local_irq_restore(flags); | ||
280 | return prev; | ||
281 | } | ||
282 | EXPORT_SYMBOL(cmpxchg_386_u8); | ||
283 | |||
284 | unsigned long cmpxchg_386_u16(volatile void *ptr, u16 old, u16 new) | ||
285 | { | ||
286 | u16 prev; | ||
287 | unsigned long flags; | ||
288 | |||
289 | /* Poor man's cmpxchg for 386. Unsuitable for SMP */ | ||
290 | local_irq_save(flags); | ||
291 | prev = *(u16 *)ptr; | ||
292 | if (prev == old) | ||
293 | *(u16 *)ptr = new; | ||
294 | local_irq_restore(flags); | ||
295 | return prev; | ||
296 | } | ||
297 | EXPORT_SYMBOL(cmpxchg_386_u16); | ||
298 | |||
299 | unsigned long cmpxchg_386_u32(volatile void *ptr, u32 old, u32 new) | ||
300 | { | ||
301 | u32 prev; | ||
302 | unsigned long flags; | ||
303 | |||
304 | /* Poor man's cmpxchg for 386. Unsuitable for SMP */ | ||
305 | local_irq_save(flags); | ||
306 | prev = *(u32 *)ptr; | ||
307 | if (prev == old) | ||
308 | *(u32 *)ptr = new; | ||
309 | local_irq_restore(flags); | ||
310 | return prev; | ||
311 | } | ||
312 | EXPORT_SYMBOL(cmpxchg_386_u32); | ||
313 | #endif | ||
314 | |||
267 | // arch_initcall(intel_cpu_init); | 315 | // arch_initcall(intel_cpu_init); |
268 | 316 | ||