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 static inline void down_read(struct rw_semaphore *sem)
37 * trylock for reading -- returns 1 if successful, 0 if contention
39 static inline int down_read_trylock(struct rw_semaphore *sem)
42 ret = __down_read_trylock(sem);
49 static inline void down_write(struct rw_semaphore *sem)
56 * trylock for writing -- returns 1 if successful, 0 if contention
58 static inline int down_write_trylock(struct rw_semaphore *sem)
61 ret = __down_write_trylock(sem);
68 static inline void up_read(struct rw_semaphore *sem)
74 * release a write lock
76 static inline void up_write(struct rw_semaphore *sem)
82 * downgrade write lock to read lock
84 static inline void downgrade_write(struct rw_semaphore *sem)
86 __downgrade_write(sem);
89 #endif /* __KERNEL__ */
90 #endif /* _LINUX_RWSEM_H */