Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / include / linux / rwlock_types.h
1 #ifndef __LINUX_RWLOCK_TYPES_H
2 #define __LINUX_RWLOCK_TYPES_H
3
4 #if !defined(__LINUX_SPINLOCK_TYPES_H)
5 # error "Do not include directly, include spinlock_types.h"
6 #endif
7
8 /*
9  * include/linux/rwlock_types.h - generic rwlock type definitions
10  *                                and initializers
11  *
12  * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
13  * Released under the General Public License (GPL).
14  */
15 typedef struct {
16         arch_rwlock_t raw_lock;
17 #ifdef CONFIG_GENERIC_LOCKBREAK
18         unsigned int break_lock;
19 #endif
20 #ifdef CONFIG_DEBUG_SPINLOCK
21         unsigned int magic, owner_cpu;
22         void *owner;
23 #endif
24 #ifdef CONFIG_DEBUG_LOCK_ALLOC
25         struct lockdep_map dep_map;
26 #endif
27 } rwlock_t;
28
29 #define RWLOCK_MAGIC            0xdeaf1eed
30
31 #ifdef CONFIG_DEBUG_LOCK_ALLOC
32 # define RW_DEP_MAP_INIT(lockname)      .dep_map = { .name = #lockname }
33 #else
34 # define RW_DEP_MAP_INIT(lockname)
35 #endif
36
37 #ifdef CONFIG_DEBUG_SPINLOCK
38 #define __RW_LOCK_UNLOCKED(lockname)                                    \
39         (rwlock_t)      {       .raw_lock = __ARCH_RW_LOCK_UNLOCKED,    \
40                                 .magic = RWLOCK_MAGIC,                  \
41                                 .owner = SPINLOCK_OWNER_INIT,           \
42                                 .owner_cpu = -1,                        \
43                                 RW_DEP_MAP_INIT(lockname) }
44 #else
45 #define __RW_LOCK_UNLOCKED(lockname) \
46         (rwlock_t)      {       .raw_lock = __ARCH_RW_LOCK_UNLOCKED,    \
47                                 RW_DEP_MAP_INIT(lockname) }
48 #endif
49
50 #define DEFINE_RWLOCK(name) \
51         rwlock_t name __cacheline_aligned_in_smp = __RW_LOCK_UNLOCKED(name)
52
53 #endif /* __LINUX_RWLOCK_TYPES_H */