summaryrefslogtreecommitdiffstats
path: root/include/asm-i386/semaphore.h
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-06-01 03:16:17 +0000
committerRalf Baechle <ralf@linux-mips.org>1997-06-01 03:16:17 +0000
commitd8d9b8f76f22b7a16a83e261e64f89ee611f49df (patch)
tree3067bc130b80d52808e6390c9fc7fc087ec1e33c /include/asm-i386/semaphore.h
parent19c9bba94152148523ba0f7ef7cffe3d45656b11 (diff)
Initial revision
Diffstat (limited to 'include/asm-i386/semaphore.h')
-rw-r--r--include/asm-i386/semaphore.h46
1 files changed, 25 insertions, 21 deletions
diff --git a/include/asm-i386/semaphore.h b/include/asm-i386/semaphore.h
index 4395dfce0..3ba3f8af5 100644
--- a/include/asm-i386/semaphore.h
+++ b/include/asm-i386/semaphore.h
@@ -85,44 +85,45 @@ extern inline void down(struct semaphore * sem)
{
__asm__ __volatile__(
"# atomic down operation\n\t"
- "movl $1f,%%eax\n\t"
#ifdef __SMP__
"lock ; "
#endif
"decl 0(%0)\n\t"
- "js " SYMBOL_NAME_STR(__down_failed)
- "\n1:"
+ "js 2f\n"
+ "1:\n"
+ ".section .text.lock,\"ax\"\n"
+ "2:\tpushl $1b\n\t"
+ "jmp __down_failed\n"
+ ".previous"
:/* no outputs */
:"c" (sem)
- :"ax","memory");
+ :"memory");
}
-/*
- * This version waits in interruptible state so that the waiting
- * process can be killed. The down_failed_interruptible routine
- * returns negative for signalled and zero for semaphore acquired.
- */
extern inline int down_interruptible(struct semaphore * sem)
{
- int ret;
+ int result;
__asm__ __volatile__(
"# atomic interruptible down operation\n\t"
- "movl $1f,%0\n\t"
#ifdef __SMP__
"lock ; "
#endif
"decl 0(%1)\n\t"
- "js " SYMBOL_NAME_STR(__down_failed_interruptible) "\n\t"
- "xorl %0,%0"
- "\n1:"
- :"=a" (ret)
+ "js 2f\n\t"
+ "xorl %0,%0\n"
+ "1:\n"
+ ".section .text.lock,\"ax\"\n"
+ "2:\tpushl $1b\n\t"
+ "jmp __down_failed_interruptible\n"
+ ".previous"
+ :"=a" (result)
:"c" (sem)
:"memory");
-
- return ret;
+ return result;
}
+
/*
* Note! This is subtle. We jump to wake people up only if
* the semaphore was negative (== somebody was waiting on it).
@@ -133,16 +134,19 @@ extern inline void up(struct semaphore * sem)
{
__asm__ __volatile__(
"# atomic up operation\n\t"
- "movl $1f,%%eax\n\t"
#ifdef __SMP__
"lock ; "
#endif
"incl 0(%0)\n\t"
- "jle " SYMBOL_NAME_STR(__up_wakeup)
- "\n1:"
+ "jle 2f\n"
+ "1:\n"
+ ".section .text.lock,\"ax\"\n"
+ "2:\tpushl $1b\n\t"
+ "jmp __up_wakeup\n"
+ ".previous"
:/* no outputs */
:"c" (sem)
- :"ax", "memory");
+ :"memory");
}
#endif