1 #ifndef __LINUX_RWLOCK_TYPES_H
2 #define __LINUX_RWLOCK_TYPES_H
4 #if !defined(__LINUX_SPINLOCK_TYPES_H)
5 # error "Do not include directly, include spinlock_types.h"
8 #ifdef CONFIG_DEBUG_LOCK_ALLOC
9 # define RW_DEP_MAP_INIT(lockname) \
12 .wait_type_inner = LD_WAIT_CONFIG, \
15 # define RW_DEP_MAP_INIT(lockname)
18 #ifndef CONFIG_PREEMPT_RT
20 * generic rwlock type definitions and initializers
22 * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
23 * Released under the General Public License (GPL).
26 arch_rwlock_t raw_lock
;
27 #ifdef CONFIG_DEBUG_SPINLOCK
28 unsigned int magic
, owner_cpu
;
31 #ifdef CONFIG_DEBUG_LOCK_ALLOC
32 struct lockdep_map dep_map
;
36 #define RWLOCK_MAGIC 0xdeaf1eed
38 #ifdef CONFIG_DEBUG_SPINLOCK
39 #define __RW_LOCK_UNLOCKED(lockname) \
40 (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \
41 .magic = RWLOCK_MAGIC, \
42 .owner = SPINLOCK_OWNER_INIT, \
44 RW_DEP_MAP_INIT(lockname) }
46 #define __RW_LOCK_UNLOCKED(lockname) \
47 (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \
48 RW_DEP_MAP_INIT(lockname) }
51 #define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x)
53 #else /* !CONFIG_PREEMPT_RT */
55 #include <linux/rwbase_rt.h>
58 struct rwbase_rt rwbase
;
60 #ifdef CONFIG_DEBUG_LOCK_ALLOC
61 struct lockdep_map dep_map
;
65 #define __RWLOCK_RT_INITIALIZER(name) \
67 .rwbase = __RWBASE_INITIALIZER(name), \
68 RW_DEP_MAP_INIT(name) \
71 #define __RW_LOCK_UNLOCKED(name) __RWLOCK_RT_INITIALIZER(name)
73 #define DEFINE_RWLOCK(name) \
74 rwlock_t name = __RW_LOCK_UNLOCKED(name)
76 #endif /* CONFIG_PREEMPT_RT */
78 #endif /* __LINUX_RWLOCK_TYPES_H */