* better
[mascara-docs.git] / i386 / linux-2.3.21 / include / asm-arm / semaphore.h
blob71509e9e86ba9d7ac86bbc8fb6391c50adc88e4e
1 /*
2 * linux/include/asm-arm/semaphore.h
3 */
4 #ifndef __ASM_ARM_SEMAPHORE_H
5 #define __ASM_ARM_SEMAPHORE_H
7 #include <linux/linkage.h>
8 #include <asm/atomic.h>
9 #include <linux/spinlock.h>
10 #include <linux/wait.h>
12 struct semaphore {
13 atomic_t count;
14 int sleepers;
15 wait_queue_head_t wait;
18 #define __SEMAPHORE_INIT(name,count) \
19 { ATOMIC_INIT(count), 0, \
20 __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) }
22 #define __MUTEX_INITIALIZER(name) \
23 __SEMAPHORE_INIT(name,1)
25 #define __DECLARE_SEMAPHORE_GENERIC(name,count) \
26 struct semaphore name = __SEMAPHORE_INIT(name,count)
28 #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
29 #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
31 #define sema_init(sem, val) \
32 do { \
33 atomic_set(&((sem)->count), (val)); \
34 (sem)->sleepers = 0; \
35 init_waitqueue_head(&(sem)->wait); \
36 } while (0)
38 static inline void init_MUTEX(struct semaphore *sem)
40 sema_init(sem, 1);
43 static inline void init_MUTEX_LOCKED(struct semaphore *sem)
45 sema_init(sem, 0);
48 asmlinkage void __down_failed (void /* special register calling convention */);
49 asmlinkage int __down_interruptible_failed (void /* special register calling convention */);
50 asmlinkage int __down_trylock_failed(void /* params in registers */);
51 asmlinkage void __up_wakeup (void /* special register calling convention */);
53 extern void __down(struct semaphore * sem);
54 extern int __down_interruptible(struct semaphore * sem);
55 extern int __down_trylock(struct semaphore * sem);
56 extern void __up(struct semaphore * sem);
58 extern spinlock_t semaphore_wake_lock;
60 #include <asm/proc/semaphore.h>
62 #endif