From d8d9b8f76f22b7a16a83e261e64f89ee611f49df Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Sun, 1 Jun 1997 03:16:17 +0000 Subject: Initial revision --- include/asm-i386/semaphore.h | 46 ++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'include/asm-i386/semaphore.h') 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 -- cgit v1.2.3