at v2.6.14 1.7 kB view raw
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 18typedef struct { 19 raw_spinlock_t raw_lock; 20#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) 21 unsigned int break_lock; 22#endif 23#ifdef CONFIG_DEBUG_SPINLOCK 24 unsigned int magic, owner_cpu; 25 void *owner; 26#endif 27} spinlock_t; 28 29#define SPINLOCK_MAGIC 0xdead4ead 30 31typedef struct { 32 raw_rwlock_t raw_lock; 33#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) 34 unsigned int break_lock; 35#endif 36#ifdef CONFIG_DEBUG_SPINLOCK 37 unsigned int magic, owner_cpu; 38 void *owner; 39#endif 40} rwlock_t; 41 42#define RWLOCK_MAGIC 0xdeaf1eed 43 44#define SPINLOCK_OWNER_INIT ((void *)-1L) 45 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, \ 51 .owner_cpu = -1 } 52#define RW_LOCK_UNLOCKED \ 53 (rwlock_t) { .raw_lock = __RAW_RW_LOCK_UNLOCKED, \ 54 .magic = RWLOCK_MAGIC, \ 55 .owner = SPINLOCK_OWNER_INIT, \ 56 .owner_cpu = -1 } 57#else 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 } 62#endif 63 64#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED 65#define DEFINE_RWLOCK(x) rwlock_t x = RW_LOCK_UNLOCKED 66 67#endif /* __LINUX_SPINLOCK_TYPES_H */