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>
19 raw_spinlock_t raw_lock;
20 #if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
21 unsigned int break_lock;
23 #ifdef CONFIG_DEBUG_SPINLOCK
24 unsigned int magic, owner_cpu;
29 #define SPINLOCK_MAGIC 0xdead4ead
32 raw_rwlock_t raw_lock;
33 #if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
34 unsigned int break_lock;
36 #ifdef CONFIG_DEBUG_SPINLOCK
37 unsigned int magic, owner_cpu;
42 #define RWLOCK_MAGIC 0xdeaf1eed
44 #define SPINLOCK_OWNER_INIT ((void *)-1L)
46 #ifdef CONFIG_DEBUG_SPINLOCK
47 # define SPIN_LOCK_UNLOCKED \
48 (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \
49 .magic = SPINLOCK_MAGIC, \
50 .owner = SPINLOCK_OWNER_INIT, \
52 #define RW_LOCK_UNLOCKED \
53 (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED, \
54 .magic = RWLOCK_MAGIC, \
55 .owner = SPINLOCK_OWNER_INIT, \
58 # define SPIN_LOCK_UNLOCKED \
59 (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED }
60 #define RW_LOCK_UNLOCKED \
61 (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED }
64 #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
65 #define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED
67 #endif /* __LINUX_SPINLOCK_TYPES_H */