patch-2.2.8 linux/include/asm-arm/proc-armv/semaphore.h
Next file: linux/include/asm-arm/proc-armv/uaccess.h
Previous file: linux/include/asm-arm/proc-armv/ptrace.h
Back to the patch index
Back to the overall index
- Lines: 33
- Date:
Sat May 8 11:06:58 1999
- Orig file:
v2.2.7/linux/include/asm-arm/proc-armv/semaphore.h
- Orig date:
Fri Jan 8 22:36:23 1999
diff -u --recursive --new-file v2.2.7/linux/include/asm-arm/proc-armv/semaphore.h linux/include/asm-arm/proc-armv/semaphore.h
@@ -60,6 +60,32 @@
return temp;
}
+extern inline int down_trylock(struct semaphore *sem)
+{
+ unsigned int cpsr, temp;
+
+ __asm__ __volatile__ ("
+ @ atomic down try lock operation
+ mrs %0, cpsr
+ orr %1, %0, #128 @ disable IRQs
+ bic %0, %0, #0x80000000 @ clear N
+ msr cpsr, %1
+ ldr %1, [%2]
+ subs %1, %1, #1
+ orrmi %0, %0, #0x80000000 @ set N
+ str %1, [%2]
+ msr cpsr, %0
+ movmi r0, %2
+ movpl r0, #0
+ blmi " SYMBOL_NAME_STR(__down_trylock_failed) "
+ mov %1, r0"
+ : "=&r" (cpsr), "=&r" (temp)
+ : "r" (sem)
+ : "r0", "lr", "cc");
+
+ return temp;
+}
+
/*
* Note! This is subtle. We jump to wake people up only if
* the semaphore was negative (== somebody was waiting on it).
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)