Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.13 61 lines 1.6 kB view raw
1/* $Id: rwsem.h,v 1.5 2001/11/18 00:12:56 davem Exp $ 2 * rwsem.h: R/W semaphores implemented using CAS 3 * 4 * Written by David S. Miller (davem@redhat.com), 2001. 5 * Derived from asm-i386/rwsem.h 6 */ 7#ifndef _SPARC64_RWSEM_H 8#define _SPARC64_RWSEM_H 9 10#ifndef _LINUX_RWSEM_H 11#error "please don't include asm/rwsem.h directly, use linux/rwsem.h instead" 12#endif 13 14#ifdef __KERNEL__ 15 16#include <linux/list.h> 17#include <linux/spinlock.h> 18#include <asm/rwsem-const.h> 19 20struct rwsem_waiter; 21 22struct rw_semaphore { 23 signed int count; 24 spinlock_t wait_lock; 25 struct list_head wait_list; 26}; 27 28#define __RWSEM_INITIALIZER(name) \ 29{ RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) } 30 31#define DECLARE_RWSEM(name) \ 32 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 33 34static __inline__ void init_rwsem(struct rw_semaphore *sem) 35{ 36 sem->count = RWSEM_UNLOCKED_VALUE; 37 spin_lock_init(&sem->wait_lock); 38 INIT_LIST_HEAD(&sem->wait_list); 39} 40 41extern void __down_read(struct rw_semaphore *sem); 42extern int __down_read_trylock(struct rw_semaphore *sem); 43extern void __down_write(struct rw_semaphore *sem); 44extern int __down_write_trylock(struct rw_semaphore *sem); 45extern void __up_read(struct rw_semaphore *sem); 46extern void __up_write(struct rw_semaphore *sem); 47extern void __downgrade_write(struct rw_semaphore *sem); 48 49static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem) 50{ 51 return atomic_add_return(delta, (atomic_t *)(&sem->count)); 52} 53 54static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem) 55{ 56 atomic_add(delta, (atomic_t *)(&sem->count)); 57} 58 59#endif /* __KERNEL__ */ 60 61#endif /* _SPARC64_RWSEM_H */