patch-2.1.34 linux/include/asm-sparc64/semaphore.h
Next file: linux/include/asm-sparc64/sigcontext.h
Previous file: linux/include/asm-sparc64/scatterlist.h
Back to the patch index
Back to the overall index
- Lines: 34
- Date:
Mon Apr 14 09:31:09 1997
- Orig file:
v2.1.33/linux/include/asm-sparc64/semaphore.h
- Orig date:
Mon Mar 17 14:54:34 1997
diff -u --recursive --new-file v2.1.33/linux/include/asm-sparc64/semaphore.h linux/include/asm-sparc64/semaphore.h
@@ -11,19 +11,27 @@
struct wait_queue * wait;
};
-#define MUTEX ((struct semaphore) { 1, 0, NULL })
-#define MUTEX_LOCKED ((struct semaphore) { 0, 0, NULL })
+#define MUTEX ((struct semaphore) { { 1 }, { 0 }, NULL })
+#define MUTEX_LOCKED ((struct semaphore) { { 0 }, { 0 }, NULL })
extern void __down(struct semaphore * sem);
+extern int __down_interruptible(struct semaphore * sem);
extern void __up(struct semaphore * sem);
+#define sema_init(sem, val) atomic_set(&((sem)->count), val)
+
extern __inline__ void down(struct semaphore * sem)
{
- for (;;) {
- if (atomic_dec_return(&sem->count) >= 0)
- break;
+ if (atomic_dec_return(&sem->count) < 0)
__down(sem);
- }
+}
+
+extern __inline__ int down_interruptible(struct semaphore *sem)
+{
+ int ret = 0;
+ if (atomic_dec_return(&sem->count) < 0)
+ ret = __down_interruptible(sem);
+ return ret;
}
extern __inline__ void up(struct semaphore * sem)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov