Commit | Line | Data |
---|---|---|
ef12f109 TG |
1 | #ifndef __LINUX_RWLOCK_TYPES_H |
2 | #define __LINUX_RWLOCK_TYPES_H | |
3 | ||
4f084ca7 TG |
4 | #if !defined(__LINUX_SPINLOCK_TYPES_H) |
5 | # error "Do not include directly, include spinlock_types.h" | |
6 | #endif | |
7 | ||
8282947f TG |
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, \ | |
13 | } | |
14 | #else | |
15 | # define RW_DEP_MAP_INIT(lockname) | |
16 | #endif | |
17 | ||
18 | #ifndef CONFIG_PREEMPT_RT | |
ef12f109 | 19 | /* |
8282947f | 20 | * generic rwlock type definitions and initializers |
ef12f109 TG |
21 | * |
22 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | |
23 | * Released under the General Public License (GPL). | |
24 | */ | |
25 | typedef struct { | |
fb3a6bbc | 26 | arch_rwlock_t raw_lock; |
ef12f109 TG |
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; | |
35 | ||
36 | #define RWLOCK_MAGIC 0xdeaf1eed | |
37 | ||
ef12f109 TG |
38 | #ifdef CONFIG_DEBUG_SPINLOCK |
39 | #define __RW_LOCK_UNLOCKED(lockname) \ | |
fb3a6bbc | 40 | (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ |
ef12f109 TG |
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) \ | |
fb3a6bbc | 47 | (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ |
ef12f109 TG |
48 | RW_DEP_MAP_INIT(lockname) } |
49 | #endif | |
50 | ||
ef12f109 TG |
51 | #define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x) |
52 | ||
8282947f TG |
53 | #else /* !CONFIG_PREEMPT_RT */ |
54 | ||
55 | #include <linux/rwbase_rt.h> | |
56 | ||
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; | |
64 | ||
65 | #define __RWLOCK_RT_INITIALIZER(name) \ | |
66 | { \ | |
67 | .rwbase = __RWBASE_INITIALIZER(name), \ | |
68 | RW_DEP_MAP_INIT(name) \ | |
69 | } | |
70 | ||
71 | #define __RW_LOCK_UNLOCKED(name) __RWLOCK_RT_INITIALIZER(name) | |
72 | ||
73 | #define DEFINE_RWLOCK(name) \ | |
74 | rwlock_t name = __RW_LOCK_UNLOCKED(name) | |
75 | ||
76 | #endif /* CONFIG_PREEMPT_RT */ | |
77 | ||
ef12f109 | 78 | #endif /* __LINUX_RWLOCK_TYPES_H */ |