patch-2.1.34 linux/include/asm-sparc/semaphore.h
Next file: linux/include/asm-sparc/smp.h
Previous file: linux/include/asm-sparc/scatterlist.h
Back to the patch index
Back to the overall index
- Lines: 32
- Date:
Mon Apr 14 09:31:09 1997
- Orig file:
v2.1.33/linux/include/asm-sparc/semaphore.h
- Orig date:
Thu Mar 27 14:40:09 1997
diff -u --recursive --new-file v2.1.33/linux/include/asm-sparc/semaphore.h linux/include/asm-sparc/semaphore.h
@@ -13,12 +13,29 @@
struct wait_queue * wait;
};
-#define MUTEX ((struct semaphore) { 1, 0, NULL })
-#define MUTEX_LOCKED ((struct semaphore) { 0, 0, NULL })
+#define MUTEX ((struct semaphore) { { (1 << 8) }, { 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)
+
+static inline int waking_non_zero(struct semaphore *sem)
+{
+ unsigned long flags;
+ int ret = 0;
+
+ save_flags(flags);
+ cli();
+ if (atomic_read(&sem->waking) > 0) {
+ atomic_dec(&sem->waking);
+ ret = 1;
+ }
+ restore_flags(flags);
+ return ret;
+}
/* This isn't quite as clever as the x86 side, I'll be fixing this
* soon enough.
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov