Blame view
include/linux/rwlock.h
4.29 KB
ef12f1099 locking: Split rw... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#ifndef __LINUX_RWLOCK_H #define __LINUX_RWLOCK_H #ifndef __LINUX_SPINLOCK_H # error "please don't include this file directly" #endif /* * rwlock related methods * * split out from spinlock.h * * portions Copyright 2005, Red Hat, Inc., Ingo Molnar * Released under the General Public License (GPL). */ #ifdef CONFIG_DEBUG_SPINLOCK extern void __rwlock_init(rwlock_t *lock, const char *name, struct lock_class_key *key); # define rwlock_init(lock) \ do { \ static struct lock_class_key __key; \ \ __rwlock_init((lock), #lock, &__key); \ } while (0) #else # define rwlock_init(lock) \ do { *(lock) = __RW_LOCK_UNLOCKED(lock); } while (0) #endif #ifdef CONFIG_DEBUG_SPINLOCK |
b97c4bc16 locking: Make spa... |
32 |
extern void do_raw_read_lock(rwlock_t *lock) __acquires(lock); |
9828ea9d7 locking: Further ... |
33 34 |
#define do_raw_read_lock_flags(lock, flags) do_raw_read_lock(lock) extern int do_raw_read_trylock(rwlock_t *lock); |
b97c4bc16 locking: Make spa... |
35 36 |
extern void do_raw_read_unlock(rwlock_t *lock) __releases(lock); extern void do_raw_write_lock(rwlock_t *lock) __acquires(lock); |
9828ea9d7 locking: Further ... |
37 38 |
#define do_raw_write_lock_flags(lock, flags) do_raw_write_lock(lock) extern int do_raw_write_trylock(rwlock_t *lock); |
b97c4bc16 locking: Make spa... |
39 |
extern void do_raw_write_unlock(rwlock_t *lock) __releases(lock); |
ef12f1099 locking: Split rw... |
40 |
#else |
b97c4bc16 locking: Make spa... |
41 |
# define do_raw_read_lock(rwlock) do {__acquire(lock); arch_read_lock(&(rwlock)->raw_lock); } while (0) |
9828ea9d7 locking: Further ... |
42 |
# define do_raw_read_lock_flags(lock, flags) \ |
b97c4bc16 locking: Make spa... |
43 |
do {__acquire(lock); arch_read_lock_flags(&(lock)->raw_lock, *(flags)); } while (0) |
9828ea9d7 locking: Further ... |
44 |
# define do_raw_read_trylock(rwlock) arch_read_trylock(&(rwlock)->raw_lock) |
b97c4bc16 locking: Make spa... |
45 46 |
# define do_raw_read_unlock(rwlock) do {arch_read_unlock(&(rwlock)->raw_lock); __release(lock); } while (0) # define do_raw_write_lock(rwlock) do {__acquire(lock); arch_write_lock(&(rwlock)->raw_lock); } while (0) |
9828ea9d7 locking: Further ... |
47 |
# define do_raw_write_lock_flags(lock, flags) \ |
b97c4bc16 locking: Make spa... |
48 |
do {__acquire(lock); arch_write_lock_flags(&(lock)->raw_lock, *(flags)); } while (0) |
9828ea9d7 locking: Further ... |
49 |
# define do_raw_write_trylock(rwlock) arch_write_trylock(&(rwlock)->raw_lock) |
b97c4bc16 locking: Make spa... |
50 |
# define do_raw_write_unlock(rwlock) do {arch_write_unlock(&(rwlock)->raw_lock); __release(lock); } while (0) |
ef12f1099 locking: Split rw... |
51 |
#endif |
e5931943d locking: Convert ... |
52 53 |
#define read_can_lock(rwlock) arch_read_can_lock(&(rwlock)->raw_lock) #define write_can_lock(rwlock) arch_write_can_lock(&(rwlock)->raw_lock) |
ef12f1099 locking: Split rw... |
54 55 56 57 58 59 |
/* * Define the various rw_lock methods. Note we define these * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various * methods are defined as nops in the case they are not required. */ |
9c1721aa4 locking: Cleanup ... |
60 61 |
#define read_trylock(lock) __cond_lock(lock, _raw_read_trylock(lock)) #define write_trylock(lock) __cond_lock(lock, _raw_write_trylock(lock)) |
ef12f1099 locking: Split rw... |
62 |
|
9c1721aa4 locking: Cleanup ... |
63 64 |
#define write_lock(lock) _raw_write_lock(lock) #define read_lock(lock) _raw_read_lock(lock) |
ef12f1099 locking: Split rw... |
65 66 67 68 69 70 |
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) #define read_lock_irqsave(lock, flags) \ do { \ typecheck(unsigned long, flags); \ |
9c1721aa4 locking: Cleanup ... |
71 |
flags = _raw_read_lock_irqsave(lock); \ |
ef12f1099 locking: Split rw... |
72 73 74 75 |
} while (0) #define write_lock_irqsave(lock, flags) \ do { \ typecheck(unsigned long, flags); \ |
9c1721aa4 locking: Cleanup ... |
76 |
flags = _raw_write_lock_irqsave(lock); \ |
ef12f1099 locking: Split rw... |
77 78 79 80 81 82 83 |
} while (0) #else #define read_lock_irqsave(lock, flags) \ do { \ typecheck(unsigned long, flags); \ |
9c1721aa4 locking: Cleanup ... |
84 |
_raw_read_lock_irqsave(lock, flags); \ |
ef12f1099 locking: Split rw... |
85 86 87 88 |
} while (0) #define write_lock_irqsave(lock, flags) \ do { \ typecheck(unsigned long, flags); \ |
9c1721aa4 locking: Cleanup ... |
89 |
_raw_write_lock_irqsave(lock, flags); \ |
ef12f1099 locking: Split rw... |
90 91 92 |
} while (0) #endif |
9c1721aa4 locking: Cleanup ... |
93 94 95 96 97 98 99 100 101 102 103 104 105 |
#define read_lock_irq(lock) _raw_read_lock_irq(lock) #define read_lock_bh(lock) _raw_read_lock_bh(lock) #define write_lock_irq(lock) _raw_write_lock_irq(lock) #define write_lock_bh(lock) _raw_write_lock_bh(lock) #define read_unlock(lock) _raw_read_unlock(lock) #define write_unlock(lock) _raw_write_unlock(lock) #define read_unlock_irq(lock) _raw_read_unlock_irq(lock) #define write_unlock_irq(lock) _raw_write_unlock_irq(lock) #define read_unlock_irqrestore(lock, flags) \ do { \ typecheck(unsigned long, flags); \ _raw_read_unlock_irqrestore(lock, flags); \ |
ef12f1099 locking: Split rw... |
106 |
} while (0) |
9c1721aa4 locking: Cleanup ... |
107 |
#define read_unlock_bh(lock) _raw_read_unlock_bh(lock) |
ef12f1099 locking: Split rw... |
108 109 110 111 |
#define write_unlock_irqrestore(lock, flags) \ do { \ typecheck(unsigned long, flags); \ |
9c1721aa4 locking: Cleanup ... |
112 |
_raw_write_unlock_irqrestore(lock, flags); \ |
ef12f1099 locking: Split rw... |
113 |
} while (0) |
9c1721aa4 locking: Cleanup ... |
114 |
#define write_unlock_bh(lock) _raw_write_unlock_bh(lock) |
ef12f1099 locking: Split rw... |
115 116 117 118 119 120 121 122 123 |
#define write_trylock_irqsave(lock, flags) \ ({ \ local_irq_save(flags); \ write_trylock(lock) ? \ 1 : ({ local_irq_restore(flags); 0; }); \ }) #endif /* __LINUX_RWLOCK_H */ |