Back to home page

OSCL-LXR

 
 

    


0001 #ifndef __LINUX_SPINLOCK_TYPES_H
0002 #define __LINUX_SPINLOCK_TYPES_H
0003 
0004 /*
0005  * include/linux/spinlock_types.h - generic spinlock type definitions
0006  *                                  and initializers
0007  *
0008  * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
0009  * Released under the General Public License (GPL).
0010  */
0011 
0012 #include <linux/spinlock_types_raw.h>
0013 
0014 #ifndef CONFIG_PREEMPT_RT
0015 
0016 /* Non PREEMPT_RT kernels map spinlock to raw_spinlock */
0017 typedef struct spinlock {
0018     union {
0019         struct raw_spinlock rlock;
0020 
0021 #ifdef CONFIG_DEBUG_LOCK_ALLOC
0022 # define LOCK_PADSIZE (offsetof(struct raw_spinlock, dep_map))
0023         struct {
0024             u8 __padding[LOCK_PADSIZE];
0025             struct lockdep_map dep_map;
0026         };
0027 #endif
0028     };
0029 } spinlock_t;
0030 
0031 #define ___SPIN_LOCK_INITIALIZER(lockname)  \
0032     {                   \
0033     .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED,  \
0034     SPIN_DEBUG_INIT(lockname)       \
0035     SPIN_DEP_MAP_INIT(lockname) }
0036 
0037 #define __SPIN_LOCK_INITIALIZER(lockname) \
0038     { { .rlock = ___SPIN_LOCK_INITIALIZER(lockname) } }
0039 
0040 #define __SPIN_LOCK_UNLOCKED(lockname) \
0041     (spinlock_t) __SPIN_LOCK_INITIALIZER(lockname)
0042 
0043 #define DEFINE_SPINLOCK(x)  spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
0044 
0045 #else /* !CONFIG_PREEMPT_RT */
0046 
0047 /* PREEMPT_RT kernels map spinlock to rt_mutex */
0048 #include <linux/rtmutex.h>
0049 
0050 typedef struct spinlock {
0051     struct rt_mutex_base    lock;
0052 #ifdef CONFIG_DEBUG_LOCK_ALLOC
0053     struct lockdep_map  dep_map;
0054 #endif
0055 } spinlock_t;
0056 
0057 #define __SPIN_LOCK_UNLOCKED(name)              \
0058     {                           \
0059         .lock = __RT_MUTEX_BASE_INITIALIZER(name.lock), \
0060         SPIN_DEP_MAP_INIT(name)             \
0061     }
0062 
0063 #define __LOCAL_SPIN_LOCK_UNLOCKED(name)            \
0064     {                           \
0065         .lock = __RT_MUTEX_BASE_INITIALIZER(name.lock), \
0066         LOCAL_SPIN_DEP_MAP_INIT(name)           \
0067     }
0068 
0069 #define DEFINE_SPINLOCK(name)                   \
0070     spinlock_t name = __SPIN_LOCK_UNLOCKED(name)
0071 
0072 #endif /* CONFIG_PREEMPT_RT */
0073 
0074 #include <linux/rwlock_types.h>
0075 
0076 #endif /* __LINUX_SPINLOCK_TYPES_H */