forked from Minki/linux
a378d9338e
We have two functions for doing exactly the same thing -- emulating cmpxchg8b on 486 and older hardware -- with different calling conventions, and yet doing the same thing. Drop the C version and use the assembly version, via alternatives, for both the local and non-local versions of cmpxchg8b. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> LKML-Reference: <AANLkTikAmaDPji-TVDarmG1yD=fwbffcsmEU=YEuP+8r@mail.gmail.com>
55 lines
1.1 KiB
C
55 lines
1.1 KiB
C
/*
|
|
* cmpxchg*() fallbacks for CPU not supporting these instructions
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/module.h>
|
|
|
|
#ifndef CONFIG_X86_CMPXCHG
|
|
unsigned long cmpxchg_386_u8(volatile void *ptr, u8 old, u8 new)
|
|
{
|
|
u8 prev;
|
|
unsigned long flags;
|
|
|
|
/* Poor man's cmpxchg for 386. Unsuitable for SMP */
|
|
local_irq_save(flags);
|
|
prev = *(u8 *)ptr;
|
|
if (prev == old)
|
|
*(u8 *)ptr = new;
|
|
local_irq_restore(flags);
|
|
return prev;
|
|
}
|
|
EXPORT_SYMBOL(cmpxchg_386_u8);
|
|
|
|
unsigned long cmpxchg_386_u16(volatile void *ptr, u16 old, u16 new)
|
|
{
|
|
u16 prev;
|
|
unsigned long flags;
|
|
|
|
/* Poor man's cmpxchg for 386. Unsuitable for SMP */
|
|
local_irq_save(flags);
|
|
prev = *(u16 *)ptr;
|
|
if (prev == old)
|
|
*(u16 *)ptr = new;
|
|
local_irq_restore(flags);
|
|
return prev;
|
|
}
|
|
EXPORT_SYMBOL(cmpxchg_386_u16);
|
|
|
|
unsigned long cmpxchg_386_u32(volatile void *ptr, u32 old, u32 new)
|
|
{
|
|
u32 prev;
|
|
unsigned long flags;
|
|
|
|
/* Poor man's cmpxchg for 386. Unsuitable for SMP */
|
|
local_irq_save(flags);
|
|
prev = *(u32 *)ptr;
|
|
if (prev == old)
|
|
*(u32 *)ptr = new;
|
|
local_irq_restore(flags);
|
|
return prev;
|
|
}
|
|
EXPORT_SYMBOL(cmpxchg_386_u32);
|
|
#endif
|