]>
Commit | Line | Data |
---|---|---|
1 | #ifndef __LINUX_RWLOCK_TYPES_H | |
2 | #define __LINUX_RWLOCK_TYPES_H | |
3 | ||
4 | /* | |
5 | * include/linux/rwlock_types.h - generic rwlock type definitions | |
6 | * and initializers | |
7 | * | |
8 | * portions Copyright 2005, Red Hat, Inc., Ingo Molnar | |
9 | * Released under the General Public License (GPL). | |
10 | */ | |
11 | typedef struct { | |
12 | arch_rwlock_t raw_lock; | |
13 | #ifdef CONFIG_DEBUG_SPINLOCK | |
14 | unsigned int magic, owner_cpu; | |
15 | void *owner; | |
16 | #endif | |
17 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | |
18 | struct lockdep_map dep_map; | |
19 | #endif | |
20 | } rwlock_t; | |
21 | ||
22 | #define RWLOCK_MAGIC 0xdeaf1eed | |
23 | ||
24 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | |
25 | # define RW_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname } | |
26 | #else | |
27 | # define RW_DEP_MAP_INIT(lockname) | |
28 | #endif | |
29 | ||
30 | #ifdef CONFIG_DEBUG_SPINLOCK | |
31 | #define __RW_LOCK_UNLOCKED(lockname) \ | |
32 | (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ | |
33 | .magic = RWLOCK_MAGIC, \ | |
34 | .owner = SPINLOCK_OWNER_INIT, \ | |
35 | .owner_cpu = -1, \ | |
36 | RW_DEP_MAP_INIT(lockname) } | |
37 | #else | |
38 | #define __RW_LOCK_UNLOCKED(lockname) \ | |
39 | (rwlock_t) { .raw_lock = __ARCH_RW_LOCK_UNLOCKED, \ | |
40 | RW_DEP_MAP_INIT(lockname) } | |
41 | #endif | |
42 | ||
43 | #define DEFINE_RWLOCK(x) rwlock_t x = __RW_LOCK_UNLOCKED(x) | |
44 | ||
45 | #endif /* __LINUX_RWLOCK_TYPES_H */ |