1ef12f109SThomas Gleixner #ifndef __LINUX_RWLOCK_TYPES_H 2ef12f109SThomas Gleixner #define __LINUX_RWLOCK_TYPES_H 3ef12f109SThomas Gleixner 44f084ca7SThomas Gleixner #if !defined(__LINUX_SPINLOCK_TYPES_H) 54f084ca7SThomas Gleixner # error "Do not include directly, include spinlock_types.h" 64f084ca7SThomas Gleixner #endif 74f084ca7SThomas Gleixner 8*8282947fSThomas Gleixner #ifdef CONFIG_DEBUG_LOCK_ALLOC 9*8282947fSThomas Gleixner # define RW_DEP_MAP_INIT(lockname) \ 10*8282947fSThomas Gleixner .dep_map = { \ 11*8282947fSThomas Gleixner .name = #lockname, \ 12*8282947fSThomas Gleixner .wait_type_inner = LD_WAIT_CONFIG, \ 13*8282947fSThomas Gleixner } 14*8282947fSThomas Gleixner #else 15*8282947fSThomas Gleixner # define RW_DEP_MAP_INIT(lockname) 16*8282947fSThomas Gleixner #endif 17*8282947fSThomas Gleixner 18*8282947fSThomas Gleixner #ifndef CONFIG_PREEMPT_RT 19ef12f109SThomas Gleixner /* 20*8282947fSThomas Gleixner * generic rwlock type definitions and initializers 21ef12f109SThomas Gleixner * 22ef12f109SThomas Gleixner * portions Copyright 2005, Red Hat, Inc., Ingo Molnar 23ef12f109SThomas Gleixner * Released under the General Public License (GPL). 24ef12f109SThomas Gleixner */ 25ef12f109SThomas Gleixner typedef struct { 26fb3a6bbcSThomas Gleixner arch_rwlock_t raw_lock; 27ef12f109SThomas Gleixner #ifdef CONFIG_DEBUG_SPINLOCK 28ef12f109SThomas Gleixner unsigned int magic, owner_cpu; 29ef12f109SThomas Gleixner void *owner; 30ef12f109SThomas Gleixner #endif 31ef12f109SThomas Gleixner #ifdef CONFIG_DEBUG_LOCK_ALLOC 32ef12f109SThomas Gleixner struct lockdep_map dep_map; 33ef12f109SThomas Gleixner #endif 34ef12f109SThomas Gleixner } rwlock_t; 35ef12f109SThomas Gleixner 36ef12f109SThomas Gleixner #define RWLOCK_MAGIC 0xdeaf1eed 37ef12f109SThomas Gleixner 38ef12f109SThomas Gleixner #ifdef CONFIG_DEBUG_SPINLOCK 39ef12f109SThomas Gleixner #define __RW_LOCK_UNLOCKED(lockname) \ 40fb3a6bbcSThomas Gleixner (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ 41ef12f109SThomas Gleixner .magic = RWLOCK_MAGIC, \ 42ef12f109SThomas Gleixner .owner = SPINLOCK_OWNER_INIT, \ 43ef12f109SThomas Gleixner .owner_cpu = -1, \ 44ef12f109SThomas Gleixner RW_DEP_MAP_INIT(lockname) } 45ef12f109SThomas Gleixner #else 46ef12f109SThomas Gleixner #define __RW_LOCK_UNLOCKED(lockname) \ 47fb3a6bbcSThomas Gleixner (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ 48ef12f109SThomas Gleixner RW_DEP_MAP_INIT(lockname) } 49ef12f109SThomas Gleixner #endif 50ef12f109SThomas Gleixner 51ef12f109SThomas Gleixner #define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x) 52ef12f109SThomas Gleixner 53*8282947fSThomas Gleixner #else /* !CONFIG_PREEMPT_RT */ 54*8282947fSThomas Gleixner 55*8282947fSThomas Gleixner #include <linux/rwbase_rt.h> 56*8282947fSThomas Gleixner 57*8282947fSThomas Gleixner typedef struct { 58*8282947fSThomas Gleixner struct rwbase_rt rwbase; 59*8282947fSThomas Gleixner atomic_t readers; 60*8282947fSThomas Gleixner #ifdef CONFIG_DEBUG_LOCK_ALLOC 61*8282947fSThomas Gleixner struct lockdep_map dep_map; 62*8282947fSThomas Gleixner #endif 63*8282947fSThomas Gleixner } rwlock_t; 64*8282947fSThomas Gleixner 65*8282947fSThomas Gleixner #define __RWLOCK_RT_INITIALIZER(name) \ 66*8282947fSThomas Gleixner { \ 67*8282947fSThomas Gleixner .rwbase = __RWBASE_INITIALIZER(name), \ 68*8282947fSThomas Gleixner RW_DEP_MAP_INIT(name) \ 69*8282947fSThomas Gleixner } 70*8282947fSThomas Gleixner 71*8282947fSThomas Gleixner #define __RW_LOCK_UNLOCKED(name) __RWLOCK_RT_INITIALIZER(name) 72*8282947fSThomas Gleixner 73*8282947fSThomas Gleixner #define DEFINE_RWLOCK(name) \ 74*8282947fSThomas Gleixner rwlock_t name = __RW_LOCK_UNLOCKED(name) 75*8282947fSThomas Gleixner 76*8282947fSThomas Gleixner #endif /* CONFIG_PREEMPT_RT */ 77*8282947fSThomas Gleixner 78ef12f109SThomas Gleixner #endif /* __LINUX_RWLOCK_TYPES_H */ 79