patch-2.1.40 linux/include/asm-m68k/semaphore.h

Next file: linux/include/asm-m68k/softirq.h
Previous file: linux/include/asm-m68k/ptrace.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.39/linux/include/asm-m68k/semaphore.h linux/include/asm-m68k/semaphore.h
@@ -73,41 +73,26 @@
  * "down_failed" is a special asm handler that calls the C
  * routine that actually waits. See arch/m68k/lib/semaphore.S
  */
-extern inline void down(struct semaphore * sem)
+extern inline void do_down(struct semaphore * sem, void (*failed)(void))
 {
 	register struct semaphore *sem1 __asm__ ("%a1") = sem;
 	__asm__ __volatile__(
 		"| atomic down operation\n\t"
-		"lea %%pc@(1f),%%a0\n\t"
 		"subql #1,%0@\n\t"
-		"jmi " SYMBOL_NAME_STR(__down_failed) "\n"
-		"1:"
+		"jmi 2f\n"
+		"1:\n"
+		".section .text.lock,\"ax\"\n"
+		".even\n"
+		"2:\tpea 1b\n\t"
+		"jbra %1\n"
+		".previous"
 		: /* no outputs */
-		: "a" (sem1)
-		: "%a0", "memory");
+		: "a" (sem1), "m" (*(unsigned char *)failed)
+		: "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)
-{
-	register int ret __asm__ ("%d0");
-	register struct semaphore *sem1 __asm__ ("%a1") = sem;
-	__asm__ __volatile__(
-		"| atomic interruptible down operation\n\t"
-		"lea %%pc@(1f),%%a0\n\t"
-		"subql #1,%1@\n\t"
-		"jmi " SYMBOL_NAME_STR(__down_failed_interruptible) "\n\t"
-		"clrl %0\n"
-		"1:"
-		: "=d" (ret)
-		: "a" (sem1)
-		: "%d0", "%a0", "memory");
-	return ret;
-}
+#define down(sem) do_down((sem),__down_failed)
+#define down_interruptible(sem) do_down((sem),__down_failed_interruptible)
 
 /*
  * Note! This is subtle. We jump to wake people up only if
@@ -120,13 +105,17 @@
 	register struct semaphore *sem1 __asm__ ("%a1") = sem;
 	__asm__ __volatile__(
 		"| atomic up operation\n\t"
-		"lea %%pc@(1f),%%a0\n\t"
-		"addql #1,%0\n\t"
-		"jle " SYMBOL_NAME_STR(__up_wakeup) "\n"
-		"1:"
+		"addql #1,%0@\n\t"
+		"jle 2f\n"
+		"1:\n"
+		".section .text.lock,\"ax\"\n"
+		".even\n"
+		"2:\tpea 1b\n\t"
+		"jbra %1\n"
+		".previous"
 		: /* no outputs */
-		: "m" (sem->count), "a" (sem1)
-		: "%a0", "memory");
+		: "a" (sem1), "m" (*(unsigned char *)__up_wakeup)
+		: "memory");
 }
 
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov