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>
16 #include <linux/types.h>
17 #include <linux/kernel.h>
18 #include <asm/system.h>
19 #include <asm/atomic.h>
23 #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
24 #include <linux/rwsem-spinlock.h> /* use a generic implementation */
26 #include <asm/rwsem.h> /* use an arch-specific implementation */
31 extern void FASTCALL(rwsemtrace(struct rw_semaphore *sem, const char *str));
33 #define rwsemtrace(SEM,FMT)
40 static inline void down_read(struct rw_semaphore *sem)
43 rwsemtrace(sem,"Entering down_read");
45 rwsemtrace(sem,"Leaving down_read");
49 * trylock for reading -- returns 1 if successful, 0 if contention
51 static inline int down_read_trylock(struct rw_semaphore *sem)
54 rwsemtrace(sem,"Entering down_read_trylock");
55 ret = __down_read_trylock(sem);
56 rwsemtrace(sem,"Leaving down_read_trylock");
63 static inline void down_write(struct rw_semaphore *sem)
66 rwsemtrace(sem,"Entering down_write");
68 rwsemtrace(sem,"Leaving down_write");
72 * trylock for writing -- returns 1 if successful, 0 if contention
74 static inline int down_write_trylock(struct rw_semaphore *sem)
77 rwsemtrace(sem,"Entering down_write_trylock");
78 ret = __down_write_trylock(sem);
79 rwsemtrace(sem,"Leaving down_write_trylock");
86 static inline void up_read(struct rw_semaphore *sem)
88 rwsemtrace(sem,"Entering up_read");
90 rwsemtrace(sem,"Leaving up_read");
94 * release a write lock
96 static inline void up_write(struct rw_semaphore *sem)
98 rwsemtrace(sem,"Entering up_write");
100 rwsemtrace(sem,"Leaving up_write");
104 * downgrade write lock to read lock
106 static inline void downgrade_write(struct rw_semaphore *sem)
108 rwsemtrace(sem,"Entering downgrade_write");
109 __downgrade_write(sem);
110 rwsemtrace(sem,"Leaving downgrade_write");
113 #endif /* __KERNEL__ */
114 #endif /* _LINUX_RWSEM_H */