Back to home page

OSCL-LXR

 
 

    


0001 #ifndef __LINUX_RWLOCK_TYPES_H
0002 #define __LINUX_RWLOCK_TYPES_H
0003 
0004 #if !defined(__LINUX_SPINLOCK_TYPES_H)
0005 # error "Do not include directly, include spinlock_types.h"
0006 #endif
0007 
0008 #ifdef CONFIG_DEBUG_LOCK_ALLOC
0009 # define RW_DEP_MAP_INIT(lockname)                  \
0010     .dep_map = {                            \
0011         .name = #lockname,                  \
0012         .wait_type_inner = LD_WAIT_CONFIG,          \
0013     }
0014 #else
0015 # define RW_DEP_MAP_INIT(lockname)
0016 #endif
0017 
0018 #ifndef CONFIG_PREEMPT_RT
0019 /*
0020  * generic rwlock type definitions and initializers
0021  *
0022  * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
0023  * Released under the General Public License (GPL).
0024  */
0025 typedef struct {
0026     arch_rwlock_t raw_lock;
0027 #ifdef CONFIG_DEBUG_SPINLOCK
0028     unsigned int magic, owner_cpu;
0029     void *owner;
0030 #endif
0031 #ifdef CONFIG_DEBUG_LOCK_ALLOC
0032     struct lockdep_map dep_map;
0033 #endif
0034 } rwlock_t;
0035 
0036 #define RWLOCK_MAGIC        0xdeaf1eed
0037 
0038 #ifdef CONFIG_DEBUG_SPINLOCK
0039 #define __RW_LOCK_UNLOCKED(lockname)                    \
0040     (rwlock_t)  {   .raw_lock = __ARCH_RW_LOCK_UNLOCKED,    \
0041                 .magic = RWLOCK_MAGIC,          \
0042                 .owner = SPINLOCK_OWNER_INIT,       \
0043                 .owner_cpu = -1,            \
0044                 RW_DEP_MAP_INIT(lockname) }
0045 #else
0046 #define __RW_LOCK_UNLOCKED(lockname) \
0047     (rwlock_t)  {   .raw_lock = __ARCH_RW_LOCK_UNLOCKED,    \
0048                 RW_DEP_MAP_INIT(lockname) }
0049 #endif
0050 
0051 #define DEFINE_RWLOCK(x)    rwlock_t x = __RW_LOCK_UNLOCKED(x)
0052 
0053 #else /* !CONFIG_PREEMPT_RT */
0054 
0055 #include <linux/rwbase_rt.h>
0056 
0057 typedef struct {
0058     struct rwbase_rt    rwbase;
0059     atomic_t        readers;
0060 #ifdef CONFIG_DEBUG_LOCK_ALLOC
0061     struct lockdep_map  dep_map;
0062 #endif
0063 } rwlock_t;
0064 
0065 #define __RWLOCK_RT_INITIALIZER(name)                   \
0066 {                                   \
0067     .rwbase = __RWBASE_INITIALIZER(name),               \
0068     RW_DEP_MAP_INIT(name)                       \
0069 }
0070 
0071 #define __RW_LOCK_UNLOCKED(name) __RWLOCK_RT_INITIALIZER(name)
0072 
0073 #define DEFINE_RWLOCK(name)                     \
0074     rwlock_t name = __RW_LOCK_UNLOCKED(name)
0075 
0076 #endif /* CONFIG_PREEMPT_RT */
0077 
0078 #endif /* __LINUX_RWLOCK_TYPES_H */