]>
Commit | Line | Data |
---|---|---|
fb1c8f93 IM |
1 | #ifndef __LINUX_SPINLOCK_TYPES_H |
2 | #define __LINUX_SPINLOCK_TYPES_H | |
3 | ||
4 | /* | |
5 | * include/linux/spinlock_types.h - generic spinlock 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 | ||
12 | #if defined(CONFIG_SMP) | |
13 | # include <asm/spinlock_types.h> | |
14 | #else | |
15 | # include <linux/spinlock_types_up.h> | |
16 | #endif | |
17 | ||
21f8ca3b PZ |
18 | #include <linux/lockdep.h> |
19 | ||
fb1c8f93 | 20 | typedef struct { |
445c8951 | 21 | arch_spinlock_t raw_lock; |
95c354fe | 22 | #ifdef CONFIG_GENERIC_LOCKBREAK |
fb1c8f93 IM |
23 | unsigned int break_lock; |
24 | #endif | |
25 | #ifdef CONFIG_DEBUG_SPINLOCK | |
26 | unsigned int magic, owner_cpu; | |
27 | void *owner; | |
28 | #endif | |
8a25d5de IM |
29 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
30 | struct lockdep_map dep_map; | |
31 | #endif | |
fb1c8f93 IM |
32 | } spinlock_t; |
33 | ||
34 | #define SPINLOCK_MAGIC 0xdead4ead | |
35 | ||
fb1c8f93 IM |
36 | #define SPINLOCK_OWNER_INIT ((void *)-1L) |
37 | ||
8a25d5de IM |
38 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
39 | # define SPIN_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname } | |
40 | #else | |
41 | # define SPIN_DEP_MAP_INIT(lockname) | |
42 | #endif | |
43 | ||
fb1c8f93 | 44 | #ifdef CONFIG_DEBUG_SPINLOCK |
e4d91918 | 45 | # define __SPIN_LOCK_UNLOCKED(lockname) \ |
edc35bd7 | 46 | (spinlock_t) { .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED, \ |
fb1c8f93 IM |
47 | .magic = SPINLOCK_MAGIC, \ |
48 | .owner = SPINLOCK_OWNER_INIT, \ | |
8a25d5de IM |
49 | .owner_cpu = -1, \ |
50 | SPIN_DEP_MAP_INIT(lockname) } | |
fb1c8f93 | 51 | #else |
e4d91918 | 52 | # define __SPIN_LOCK_UNLOCKED(lockname) \ |
edc35bd7 | 53 | (spinlock_t) { .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED, \ |
8a25d5de | 54 | SPIN_DEP_MAP_INIT(lockname) } |
fb1c8f93 IM |
55 | #endif |
56 | ||
d1ab824b | 57 | /* |
ef12f109 TG |
58 | * SPIN_LOCK_UNLOCKED defeats lockdep state tracking and is hence |
59 | * deprecated. | |
60 | * Please use DEFINE_SPINLOCK() or __SPIN_LOCK_UNLOCKED() as | |
61 | * appropriate. | |
d1ab824b | 62 | */ |
e4d91918 | 63 | #define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED(old_style_spin_init) |
e4d91918 IM |
64 | |
65 | #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x) | |
ef12f109 TG |
66 | |
67 | #include <linux/rwlock_types.h> | |
fb1c8f93 IM |
68 | |
69 | #endif /* __LINUX_SPINLOCK_TYPES_H */ |