1 /* rwsem.h: R/W semaphores, public interface
3 * Written by David Howells (dhowells@redhat.com).
4 * Derived from asm-i386/semaphore.h
10 #include <linux/linkage.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <asm/system.h>
17 #include <asm/atomic.h>
21 #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
22 #include <linux/rwsem-spinlock.h> /* use a generic implementation */
24 #include <asm/rwsem.h> /* use an arch-specific implementation */
30 extern void down_read(struct rw_semaphore *sem);
33 * trylock for reading -- returns 1 if successful, 0 if contention
35 extern int down_read_trylock(struct rw_semaphore *sem);
40 extern void down_write(struct rw_semaphore *sem);
43 * trylock for writing -- returns 1 if successful, 0 if contention
45 extern int down_write_trylock(struct rw_semaphore *sem);
50 extern void up_read(struct rw_semaphore *sem);
53 * release a write lock
55 extern void up_write(struct rw_semaphore *sem);
58 * downgrade write lock to read lock
60 extern void downgrade_write(struct rw_semaphore *sem);
62 #ifdef CONFIG_DEBUG_LOCK_ALLOC
66 extern void down_read_nested(struct rw_semaphore *sem, int subclass);
67 extern void down_write_nested(struct rw_semaphore *sem, int subclass);
69 * Take/release a lock when not the owner will release it:
71 extern void down_read_non_owner(struct rw_semaphore *sem);
72 extern void up_read_non_owner(struct rw_semaphore *sem);
74 # define down_read_nested(sem, subclass) down_read(sem)
75 # define down_write_nested(sem, subclass) down_write(sem)
76 # define down_read_non_owner(sem) down_read(sem)
77 # define up_read_non_owner(sem) up_read(sem)
80 #endif /* __KERNEL__ */
81 #endif /* _LINUX_RWSEM_H */