patch-2.1.34 linux/include/asm-alpha/semaphore.h
Next file: linux/include/asm-alpha/softirq.h
Previous file: linux/include/asm-alpha/io.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-alpha/semaphore.h
-  Orig date: 
Wed Jan 15 18:47:21 1997
diff -u --recursive --new-file v2.1.33/linux/include/asm-alpha/semaphore.h linux/include/asm-alpha/semaphore.h
@@ -15,12 +15,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 }, { 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, but the gp register
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov