1 #ifndef __LINUX_SPINLOCK_TYPES_H
2 #define __LINUX_SPINLOCK_TYPES_H
5 * include/linux/spinlock_types.h - generic spinlock type definitions
8 * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
9 * Released under the General Public License (GPL).
12 #if defined(CONFIG_SMP)
13 # include <asm/spinlock_types.h>
15 # include <linux/spinlock_types_up.h>
18 #include <linux/lockdep.h>
21 arch_spinlock_t raw_lock;
22 #ifdef CONFIG_GENERIC_LOCKBREAK
23 unsigned int break_lock;
25 #ifdef CONFIG_DEBUG_SPINLOCK
26 unsigned int magic, owner_cpu;
29 #ifdef CONFIG_DEBUG_LOCK_ALLOC
30 struct lockdep_map dep_map;
34 #define SPINLOCK_MAGIC 0xdead4ead
36 #define SPINLOCK_OWNER_INIT ((void *)-1L)
38 #ifdef CONFIG_DEBUG_LOCK_ALLOC
39 # define SPIN_DEP_MAP_INIT(lockname) .dep_map = { .name = #lockname }
41 # define SPIN_DEP_MAP_INIT(lockname)
44 #ifdef CONFIG_DEBUG_SPINLOCK
45 # define __SPIN_LOCK_UNLOCKED(lockname) \
46 (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \
47 .magic = SPINLOCK_MAGIC, \
48 .owner = SPINLOCK_OWNER_INIT, \
50 SPIN_DEP_MAP_INIT(lockname) }
52 # define __SPIN_LOCK_UNLOCKED(lockname) \
53 (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \
54 SPIN_DEP_MAP_INIT(lockname) }
58 * SPIN_LOCK_UNLOCKED defeats lockdep state tracking and is hence
60 * Please use DEFINE_SPINLOCK() or __SPIN_LOCK_UNLOCKED() as
63 #define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED(old_style_spin_init)
65 #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
67 #include <linux/rwlock_types.h>
69 #endif /* __LINUX_SPINLOCK_TYPES_H */