x86: Unify rwlock assembly implementation
[deliverable/linux.git] / arch / x86 / lib / semaphore_32.S
1 /*
2 * i386 semaphore implementation.
3 *
4 * (C) Copyright 1999 Linus Torvalds
5 *
6 * Portions Copyright 1999 Red Hat, Inc.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 *
13 * rw semaphores implemented November 1999 by Benjamin LaHaise <bcrl@kvack.org>
14 */
15
16 #include <linux/linkage.h>
17 #include <asm/frame.h>
18 #include <asm/dwarf2.h>
19
20 /*
21 * The semaphore operations have a special calling sequence that
22 * allow us to do a simpler in-line version of them. These routines
23 * need to convert that sequence back into the C sequence when
24 * there is contention on the semaphore.
25 *
26 * %eax contains the semaphore pointer on entry. Save the C-clobbered
27 * registers (%eax, %edx and %ecx) except %eax whish is either a return
28 * value or just clobbered..
29 */
30 .section .sched.text, "ax"
31
32 /* Fix up special calling conventions */
33 ENTRY(call_rwsem_down_read_failed)
34 CFI_STARTPROC
35 pushl_cfi %ecx
36 CFI_REL_OFFSET ecx,0
37 pushl_cfi %edx
38 CFI_REL_OFFSET edx,0
39 call rwsem_down_read_failed
40 popl_cfi %edx
41 popl_cfi %ecx
42 ret
43 CFI_ENDPROC
44 ENDPROC(call_rwsem_down_read_failed)
45
46 ENTRY(call_rwsem_down_write_failed)
47 CFI_STARTPROC
48 pushl_cfi %ecx
49 CFI_REL_OFFSET ecx,0
50 calll rwsem_down_write_failed
51 popl_cfi %ecx
52 ret
53 CFI_ENDPROC
54 ENDPROC(call_rwsem_down_write_failed)
55
56 ENTRY(call_rwsem_wake)
57 CFI_STARTPROC
58 decw %dx /* do nothing if still outstanding active readers */
59 jnz 1f
60 pushl_cfi %ecx
61 CFI_REL_OFFSET ecx,0
62 call rwsem_wake
63 popl_cfi %ecx
64 1: ret
65 CFI_ENDPROC
66 ENDPROC(call_rwsem_wake)
67
68 /* Fix up special calling conventions */
69 ENTRY(call_rwsem_downgrade_wake)
70 CFI_STARTPROC
71 pushl_cfi %ecx
72 CFI_REL_OFFSET ecx,0
73 pushl_cfi %edx
74 CFI_REL_OFFSET edx,0
75 call rwsem_downgrade_wake
76 popl_cfi %edx
77 popl_cfi %ecx
78 ret
79 CFI_ENDPROC
80 ENDPROC(call_rwsem_downgrade_wake)
This page took 0.032679 seconds and 5 git commands to generate.