1 #ifndef _SPARC64_SEMAPHORE_H
2 #define _SPARC64_SEMAPHORE_H
4 /* These are actually reasonable on the V9.
6 * See asm-ppc/semaphore.h for implementation commentary,
7 * only sparc64 specific issues are commented here.
11 #include <asm/atomic.h>
12 #include <asm/system.h>
13 #include <linux/wait.h>
14 #include <linux/rwsem.h>
18 wait_queue_head_t wait;
21 #define __SEMAPHORE_INITIALIZER(name, count) \
22 { ATOMIC_INIT(count), \
23 __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) }
25 #define __MUTEX_INITIALIZER(name) \
26 __SEMAPHORE_INITIALIZER(name, 1)
28 #define __DECLARE_SEMAPHORE_GENERIC(name, count) \
29 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
31 #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
32 #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name, 0)
34 static inline void sema_init (struct semaphore *sem, int val)
36 atomic_set(&sem->count, val);
37 init_waitqueue_head(&sem->wait);
40 static inline void init_MUTEX (struct semaphore *sem)
45 static inline void init_MUTEX_LOCKED (struct semaphore *sem)
50 extern void up(struct semaphore *sem);
51 extern void down(struct semaphore *sem);
52 extern int down_trylock(struct semaphore *sem);
53 extern int down_interruptible(struct semaphore *sem);
55 #endif /* __KERNEL__ */
57 #endif /* !(_SPARC64_SEMAPHORE_H) */