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 #include <linux/spinlock_types_raw.h>
14 #ifndef CONFIG_PREEMPT_RT
16 /* Non PREEMPT_RT kernels map spinlock to raw_spinlock */
17 typedef struct spinlock {
19 struct raw_spinlock rlock;
21 #ifdef CONFIG_DEBUG_LOCK_ALLOC
22 # define LOCK_PADSIZE (offsetof(struct raw_spinlock, dep_map))
24 u8 __padding[LOCK_PADSIZE];
25 struct lockdep_map dep_map;
31 #define ___SPIN_LOCK_INITIALIZER(lockname) \
33 .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED, \
34 SPIN_DEBUG_INIT(lockname) \
35 SPIN_DEP_MAP_INIT(lockname) }
37 #define __SPIN_LOCK_INITIALIZER(lockname) \
38 { { .rlock = ___SPIN_LOCK_INITIALIZER(lockname) } }
40 #define __SPIN_LOCK_UNLOCKED(lockname) \
41 (spinlock_t) __SPIN_LOCK_INITIALIZER(lockname)
43 #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
45 #else /* !CONFIG_PREEMPT_RT */
47 /* PREEMPT_RT kernels map spinlock to rt_mutex */
48 #include <linux/rtmutex.h>
50 typedef struct spinlock {
51 struct rt_mutex_base lock;
52 #ifdef CONFIG_DEBUG_LOCK_ALLOC
53 struct lockdep_map dep_map;
57 #define __SPIN_LOCK_UNLOCKED(name) \
59 .lock = __RT_MUTEX_BASE_INITIALIZER(name.lock), \
60 SPIN_DEP_MAP_INIT(name) \
63 #define __LOCAL_SPIN_LOCK_UNLOCKED(name) \
65 .lock = __RT_MUTEX_BASE_INITIALIZER(name.lock), \
66 LOCAL_SPIN_DEP_MAP_INIT(name) \
69 #define DEFINE_SPINLOCK(name) \
70 spinlock_t name = __SPIN_LOCK_UNLOCKED(name)
72 #endif /* CONFIG_PREEMPT_RT */
74 #include <linux/rwlock_types.h>
76 #endif /* __LINUX_SPINLOCK_TYPES_H */