Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 703ccb63ae9f7444d6ff876d024e17f628103c69 78 lines 1.9 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#include <linux/spinlock_types_raw.h> 13 14#ifndef CONFIG_PREEMPT_RT 15 16/* Non PREEMPT_RT kernels map spinlock to raw_spinlock */ 17context_lock_struct(spinlock) { 18 union { 19 struct raw_spinlock rlock; 20 21#ifdef CONFIG_DEBUG_LOCK_ALLOC 22# define LOCK_PADSIZE (offsetof(struct raw_spinlock, dep_map)) 23 struct { 24 u8 __padding[LOCK_PADSIZE]; 25 struct lockdep_map dep_map; 26 }; 27#endif 28 }; 29}; 30typedef struct spinlock spinlock_t; 31 32#define ___SPIN_LOCK_INITIALIZER(lockname) \ 33 { \ 34 .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED, \ 35 SPIN_DEBUG_INIT(lockname) \ 36 SPIN_DEP_MAP_INIT(lockname) } 37 38#define __SPIN_LOCK_INITIALIZER(lockname) \ 39 { { .rlock = ___SPIN_LOCK_INITIALIZER(lockname) } } 40 41#define __SPIN_LOCK_UNLOCKED(lockname) \ 42 (spinlock_t) __SPIN_LOCK_INITIALIZER(lockname) 43 44#define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x) 45 46#else /* !CONFIG_PREEMPT_RT */ 47 48/* PREEMPT_RT kernels map spinlock to rt_mutex */ 49#include <linux/rtmutex.h> 50 51context_lock_struct(spinlock) { 52 struct rt_mutex_base lock; 53#ifdef CONFIG_DEBUG_LOCK_ALLOC 54 struct lockdep_map dep_map; 55#endif 56}; 57typedef struct spinlock spinlock_t; 58 59#define __SPIN_LOCK_UNLOCKED(name) \ 60 { \ 61 .lock = __RT_MUTEX_BASE_INITIALIZER(name.lock), \ 62 SPIN_DEP_MAP_INIT(name) \ 63 } 64 65#define __LOCAL_SPIN_LOCK_UNLOCKED(name) \ 66 { \ 67 .lock = __RT_MUTEX_BASE_INITIALIZER(name.lock), \ 68 LOCAL_SPIN_DEP_MAP_INIT(name) \ 69 } 70 71#define DEFINE_SPINLOCK(name) \ 72 spinlock_t name = __SPIN_LOCK_UNLOCKED(name) 73 74#endif /* CONFIG_PREEMPT_RT */ 75 76#include <linux/rwlock_types.h> 77 78#endif /* __LINUX_SPINLOCK_TYPES_H */