Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / linux / rwlock_types.h
blob1948442e77501beeba9ad2b50de26e432e63f338
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"
6 #endif
8 #ifdef CONFIG_DEBUG_LOCK_ALLOC
9 # define RW_DEP_MAP_INIT(lockname) \
10 .dep_map = { \
11 .name = #lockname, \
12 .wait_type_inner = LD_WAIT_CONFIG, \
14 #else
15 # define RW_DEP_MAP_INIT(lockname)
16 #endif
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).
25 typedef struct {
26 arch_rwlock_t raw_lock;
27 #ifdef CONFIG_DEBUG_SPINLOCK
28 unsigned int magic, owner_cpu;
29 void *owner;
30 #endif
31 #ifdef CONFIG_DEBUG_LOCK_ALLOC
32 struct lockdep_map dep_map;
33 #endif
34 } rwlock_t;
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, \
43 .owner_cpu = -1, \
44 RW_DEP_MAP_INIT(lockname) }
45 #else
46 #define __RW_LOCK_UNLOCKED(lockname) \
47 (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \
48 RW_DEP_MAP_INIT(lockname) }
49 #endif
51 #define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x)
53 #else /* !CONFIG_PREEMPT_RT */
55 #include <linux/rwbase_rt.h>
57 typedef struct {
58 struct rwbase_rt rwbase;
59 atomic_t readers;
60 #ifdef CONFIG_DEBUG_LOCK_ALLOC
61 struct lockdep_map dep_map;
62 #endif
63 } rwlock_t;
65 #define __RWLOCK_RT_INITIALIZER(name) \
66 { \
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 */