Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
arch
x86
lib
cmpxchg.c
Go to the documentation of this file.
1
/*
2
* cmpxchg*() fallbacks for CPU not supporting these instructions
3
*/
4
5
#include <linux/kernel.h>
6
#include <
linux/smp.h
>
7
#include <linux/module.h>
8
9
#ifndef CONFIG_X86_CMPXCHG
10
unsigned
long
cmpxchg_386_u8
(
volatile
void
*
ptr
,
u8
old,
u8
new
)
11
{
12
u8
prev
;
13
unsigned
long
flags
;
14
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
;
22
}
23
EXPORT_SYMBOL
(
cmpxchg_386_u8
);
24
25
unsigned
long
cmpxchg_386_u16
(
volatile
void
*
ptr
,
u16
old,
u16
new
)
26
{
27
u16
prev
;
28
unsigned
long
flags
;
29
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
;
37
}
38
EXPORT_SYMBOL
(
cmpxchg_386_u16
);
39
40
unsigned
long
cmpxchg_386_u32
(
volatile
void
*
ptr
,
u32
old,
u32
new
)
41
{
42
u32
prev
;
43
unsigned
long
flags
;
44
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
;
52
}
53
EXPORT_SYMBOL
(
cmpxchg_386_u32
);
54
#endif
Generated on Thu Jan 10 2013 13:21:22 for Linux Kernel by
1.8.2