2 * i386 semaphore implementation.
4 * (C) Copyright 1999 Linus Torvalds
6 * Portions Copyright 1999 Red Hat, Inc.
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.
13 * rw semaphores implemented November 1999 by Benjamin LaHaise <bcrl@kvack.org>
15 #include <linux/config.h>
16 #include <asm/semaphore.h>
19 * The semaphore operations have a special calling sequence that
20 * allow us to do a simpler in-line version of them. These routines
21 * need to convert that sequence back into the C sequence when
22 * there is contention on the semaphore.
24 * %eax contains the semaphore pointer on entry. Save the C-clobbered
25 * registers (%eax, %edx and %ecx) except %eax whish is either a return
26 * value or just clobbered..
29 ".section .sched.text\n"
31 ".globl __down_failed\n"
33 #if defined(CONFIG_FRAME_POINTER)
42 #if defined(CONFIG_FRAME_POINTER)
50 ".section .sched.text\n"
52 ".globl __down_failed_interruptible\n"
53 "__down_failed_interruptible:\n\t"
54 #if defined(CONFIG_FRAME_POINTER)
60 "call __down_interruptible\n\t"
63 #if defined(CONFIG_FRAME_POINTER)
71 ".section .sched.text\n"
73 ".globl __down_failed_trylock\n"
74 "__down_failed_trylock:\n\t"
75 #if defined(CONFIG_FRAME_POINTER)
81 "call __down_trylock\n\t"
84 #if defined(CONFIG_FRAME_POINTER)
92 ".section .sched.text\n"
94 ".globl __up_wakeup\n"
105 * rw spinlock fallbacks
107 #if defined(CONFIG_SMP)
109 ".section .sched.text\n"
111 ".globl __write_lock_failed\n"
112 "__write_lock_failed:\n\t"
113 LOCK "addl $" RW_LOCK_BIAS_STR ",(%eax)\n"
115 "cmpl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
117 LOCK "subl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
118 "jnz __write_lock_failed\n\t"
123 ".section .sched.text\n"
125 ".globl __read_lock_failed\n"
126 "__read_lock_failed:\n\t"
131 LOCK "decl (%eax)\n\t"
132 "js __read_lock_failed\n\t"