Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 #ifndef __LINUX_SPINLOCK_TYPES_H
  2 #define __LINUX_SPINLOCK_TYPES_H
  3 
  4 /*
  5  * include/linux/spinlock_types.h - generic spinlock type definitions
  6  *                                  and initializers
  7  *
  8  * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
  9  * Released under the General Public License (GPL).
 10  */
 11 
 12 #if defined(CONFIG_SMP)
 13 # include <asm/spinlock_types.h>
 14 #else
 15 # include <linux/spinlock_types_up.h>
 16 #endif
 17 
 18 /*
 19  * Must define these before including other files, inline functions need them
 20  */
 21 #define LOCK_SECTION_NAME ".text.lock."KBUILD_BASENAME
 22 
 23 #define LOCK_SECTION_START(extra)               \
 24         ".subsection 1\n\t"                     \
 25         extra                                   \
 26         ".ifndef " LOCK_SECTION_NAME "\n\t"     \
 27         LOCK_SECTION_NAME ":\n\t"               \
 28         ".endif\n"
 29 
 30 #define LOCK_SECTION_END                        \
 31         ".previous\n\t"
 32 
 33 #define __lockfunc  __attribute__((section(".spinlock.text")))
 34 
 35 #include <linux/lockdep.h>
 36 
 37 typedef struct {
 38         __raw_spinlock_t raw_lock;
 39 #ifdef CONFIG_GENERIC_LOCKBREAK
 40         unsigned int break_lock;
 41 #endif
 42 #ifdef CONFIG_DEBUG_SPINLOCK
 43         unsigned int magic, owner_cpu;
 44         void *owner;
 45 #endif
 46 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 47         struct lockdep_map dep_map;
 48 #endif
 49 } raw_spinlock_t;
 50 
 51 #define SPINLOCK_MAGIC          0xdead4ead
 52 
 53 typedef struct {
 54         __raw_rwlock_t raw_lock;
 55 #ifdef CONFIG_GENERIC_LOCKBREAK
 56         unsigned int break_lock;
 57 #endif
 58 #ifdef CONFIG_DEBUG_SPINLOCK
 59         unsigned int magic, owner_cpu;
 60         void *owner;
 61 #endif
 62 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 63         struct lockdep_map dep_map;
 64 #endif
 65 } raw_rwlock_t;
 66 
 67 #define RWLOCK_MAGIC            0xdeaf1eed
 68 
 69 #define SPINLOCK_OWNER_INIT     ((void *)-1L)
 70 
 71 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 72 # define SPIN_DEP_MAP_INIT(lockname)    .dep_map = { .name = #lockname }
 73 #else
 74 # define SPIN_DEP_MAP_INIT(lockname)
 75 #endif
 76 
 77 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 78 # define RW_DEP_MAP_INIT(lockname)      .dep_map = { .name = #lockname }
 79 #else
 80 # define RW_DEP_MAP_INIT(lockname)
 81 #endif
 82 
 83 #ifdef CONFIG_DEBUG_SPINLOCK
 84 # define _RAW_SPIN_LOCK_UNLOCKED(lockname)                              \
 85                         {       .raw_lock = __RAW_SPIN_LOCK_UNLOCKED,   \
 86                                 .magic = SPINLOCK_MAGIC,                \
 87                                 .owner = SPINLOCK_OWNER_INIT,           \
 88                                 .owner_cpu = -1,                        \
 89                                 SPIN_DEP_MAP_INIT(lockname) }
 90 #define _RAW_RW_LOCK_UNLOCKED(lockname)                                 \
 91                         {       .raw_lock = __RAW_RW_LOCK_UNLOCKED,     \
 92                                 .magic = RWLOCK_MAGIC,                  \
 93                                 .owner = SPINLOCK_OWNER_INIT,           \
 94                                 .owner_cpu = -1,                        \
 95                                 RW_DEP_MAP_INIT(lockname) }
 96 #else
 97 # define _RAW_SPIN_LOCK_UNLOCKED(lockname)                              \
 98                         {       .raw_lock = __RAW_SPIN_LOCK_UNLOCKED,   \
 99                                 SPIN_DEP_MAP_INIT(lockname) }
100 # define _RAW_RW_LOCK_UNLOCKED(lockname)                                \
101                         {       .raw_lock = __RAW_RW_LOCK_UNLOCKED,     \
102                                 RW_DEP_MAP_INIT(lockname) }
103 #endif
104 
105 /*
106  * SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED defeat lockdep state tracking and
107  * are hence deprecated.
108  * Please use DEFINE_SPINLOCK()/DEFINE_RWLOCK() or
109  * __SPIN_LOCK_UNLOCKED()/__RW_LOCK_UNLOCKED() as appropriate.
110  */
111 
112 # define RAW_SPIN_LOCK_UNLOCKED(lockname) \
113         (raw_spinlock_t) _RAW_SPIN_LOCK_UNLOCKED(lockname)
114 
115 # define RAW_RW_LOCK_UNLOCKED(lockname) \
116         (raw_rwlock_t) _RAW_RW_LOCK_UNLOCKED(lockname)
117 
118 #define DEFINE_RAW_SPINLOCK(name) \
119         raw_spinlock_t name __cacheline_aligned_in_smp = \
120                 RAW_SPIN_LOCK_UNLOCKED(name)
121 
122 #define __DEFINE_RAW_SPINLOCK(name) \
123         raw_spinlock_t name = RAW_SPIN_LOCK_UNLOCKED(name)
124 
125 #define DEFINE_RAW_RWLOCK(name) \
126         raw_rwlock_t name __cacheline_aligned_in_smp = \
127                 RAW_RW_LOCK_UNLOCKED(name)
128 
129 #endif /* __LINUX_SPINLOCK_TYPES_H */
130 
  This page was automatically generated by the LXR engine.