2 * SMP- and interrupt-safe semaphores helper functions. Generic versions, no
3 * optimizations whatsoever...
7 #ifndef _ASM_SEMAPHORE_HELPER_H
8 #define _ASM_SEMAPHORE_HELPER_H
10 #include <asm/atomic.h>
12 #define read(a) ((a)->counter)
13 #define inc(a) (((a)->counter)++)
14 #define dec(a) (((a)->counter)--)
16 #define count_inc(a) ((*(a))++)
19 * These two _must_ execute atomically wrt each other.
21 extern inline void wake_one_more(struct semaphore * sem)
23 atomic_inc(&sem->waking);
26 extern inline int waking_non_zero(struct semaphore *sem)
32 if (read(&sem->waking) > 0) {
40 extern inline int waking_non_zero_interruptible(struct semaphore *sem,
41 struct task_struct *tsk)
47 if (read(&sem->waking) > 0) {
50 } else if (signal_pending(tsk)) {
51 count_inc(&sem->count);
58 extern inline int waking_non_zero_trylock(struct semaphore *sem)
64 if (read(&sem->waking) <= 0)
65 count_inc(&sem->count);
74 #endif /* _ASM_SEMAPHORE_HELPER_H */