mm: page_alloc: embed OOM killing naturally into allocation slowpath
[linux-2.6/btrfs-unstable.git] / arch / x86 / lib / cmpxchg8b_emu.S
blobb4807fce517760ac4a72dceae939ae322b0bda6b
1 /*
2  *      This program is free software; you can redistribute it and/or
3  *      modify it under the terms of the GNU General Public License
4  *      as published by the Free Software Foundation; version 2
5  *      of the License.
6  *
7  */
9 #include <linux/linkage.h>
10 #include <asm/dwarf2.h>
12 .text
15  * Inputs:
16  * %esi : memory location to compare
17  * %eax : low 32 bits of old value
18  * %edx : high 32 bits of old value
19  * %ebx : low 32 bits of new value
20  * %ecx : high 32 bits of new value
21  */
22 ENTRY(cmpxchg8b_emu)
23 CFI_STARTPROC
26 # Emulate 'cmpxchg8b (%esi)' on UP except we don't
27 # set the whole ZF thing (caller will just compare
28 # eax:edx with the expected value)
30         pushfl_cfi
31         cli
33         cmpl  (%esi), %eax
34         jne .Lnot_same
35         cmpl 4(%esi), %edx
36         jne .Lhalf_same
38         movl %ebx,  (%esi)
39         movl %ecx, 4(%esi)
41         CFI_REMEMBER_STATE
42         popfl_cfi
43         ret
45         CFI_RESTORE_STATE
46 .Lnot_same:
47         movl  (%esi), %eax
48 .Lhalf_same:
49         movl 4(%esi), %edx
51         popfl_cfi
52         ret
54 CFI_ENDPROC
55 ENDPROC(cmpxchg8b_emu)