diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-21 10:36:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-21 10:36:42 -0400 |
commit | 6d9c5d94d39a09d9b112613f0bfdb9af0e6dc253 (patch) | |
tree | ccfdb83a12f3cc582717c59e219150c6a00b4e16 | |
parent | 858eaca169ed5e7b1b14eebb889323e75a02af0e (diff) | |
parent | 489ec5f5d59b306e4ccc505eac417526adedb438 (diff) |
Merge rsync://rsync.kernel.org/pub/linux/kernel/people/davem/sparc-2.6.git
-rw-r--r-- | include/asm-sparc64/spinlock.h | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/include/asm-sparc64/spinlock.h b/include/asm-sparc64/spinlock.h index 11efa474865b..d1f91a4f24ae 100644 --- a/include/asm-sparc64/spinlock.h +++ b/include/asm-sparc64/spinlock.h | |||
@@ -31,15 +31,20 @@ | |||
31 | 31 | ||
32 | #ifndef CONFIG_DEBUG_SPINLOCK | 32 | #ifndef CONFIG_DEBUG_SPINLOCK |
33 | 33 | ||
34 | typedef unsigned char spinlock_t; | 34 | typedef struct { |
35 | #define SPIN_LOCK_UNLOCKED 0 | 35 | volatile unsigned char lock; |
36 | #ifdef CONFIG_PREEMPT | ||
37 | unsigned int break_lock; | ||
38 | #endif | ||
39 | } spinlock_t; | ||
40 | #define SPIN_LOCK_UNLOCKED (spinlock_t) {0,} | ||
36 | 41 | ||
37 | #define spin_lock_init(lock) (*((unsigned char *)(lock)) = 0) | 42 | #define spin_lock_init(lp) do { *(lp)= SPIN_LOCK_UNLOCKED; } while(0) |
38 | #define spin_is_locked(lock) (*((volatile unsigned char *)(lock)) != 0) | 43 | #define spin_is_locked(lp) ((lp)->lock != 0) |
39 | 44 | ||
40 | #define spin_unlock_wait(lock) \ | 45 | #define spin_unlock_wait(lp) \ |
41 | do { membar("#LoadLoad"); \ | 46 | do { membar("#LoadLoad"); \ |
42 | } while(*((volatile unsigned char *)lock)) | 47 | } while(lp->lock) |
43 | 48 | ||
44 | static inline void _raw_spin_lock(spinlock_t *lock) | 49 | static inline void _raw_spin_lock(spinlock_t *lock) |
45 | { | 50 | { |
@@ -109,20 +114,19 @@ static inline void _raw_spin_lock_flags(spinlock_t *lock, unsigned long flags) | |||
109 | #else /* !(CONFIG_DEBUG_SPINLOCK) */ | 114 | #else /* !(CONFIG_DEBUG_SPINLOCK) */ |
110 | 115 | ||
111 | typedef struct { | 116 | typedef struct { |
112 | unsigned char lock; | 117 | volatile unsigned char lock; |
113 | unsigned int owner_pc, owner_cpu; | 118 | unsigned int owner_pc, owner_cpu; |
119 | #ifdef CONFIG_PREEMPT | ||
120 | unsigned int break_lock; | ||
121 | #endif | ||
114 | } spinlock_t; | 122 | } spinlock_t; |
115 | #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0, 0xff } | 123 | #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0, 0, 0xff } |
116 | #define spin_lock_init(__lock) \ | 124 | #define spin_lock_init(lp) do { *(lp)= SPIN_LOCK_UNLOCKED; } while(0) |
117 | do { (__lock)->lock = 0; \ | 125 | #define spin_is_locked(__lock) ((__lock)->lock != 0) |
118 | (__lock)->owner_pc = 0; \ | ||
119 | (__lock)->owner_cpu = 0xff; \ | ||
120 | } while(0) | ||
121 | #define spin_is_locked(__lock) (*((volatile unsigned char *)(&((__lock)->lock))) != 0) | ||
122 | #define spin_unlock_wait(__lock) \ | 126 | #define spin_unlock_wait(__lock) \ |
123 | do { \ | 127 | do { \ |
124 | membar("#LoadLoad"); \ | 128 | membar("#LoadLoad"); \ |
125 | } while(*((volatile unsigned char *)(&((__lock)->lock)))) | 129 | } while((__lock)->lock) |
126 | 130 | ||
127 | extern void _do_spin_lock (spinlock_t *lock, char *str); | 131 | extern void _do_spin_lock (spinlock_t *lock, char *str); |
128 | extern void _do_spin_unlock (spinlock_t *lock); | 132 | extern void _do_spin_unlock (spinlock_t *lock); |
@@ -139,8 +143,13 @@ extern int _do_spin_trylock (spinlock_t *lock); | |||
139 | 143 | ||
140 | #ifndef CONFIG_DEBUG_SPINLOCK | 144 | #ifndef CONFIG_DEBUG_SPINLOCK |
141 | 145 | ||
142 | typedef unsigned int rwlock_t; | 146 | typedef struct { |
143 | #define RW_LOCK_UNLOCKED 0 | 147 | volatile unsigned int lock; |
148 | #ifdef CONFIG_PREEMPT | ||
149 | unsigned int break_lock; | ||
150 | #endif | ||
151 | } rwlock_t; | ||
152 | #define RW_LOCK_UNLOCKED {0,} | ||
144 | #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) | 153 | #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) |
145 | 154 | ||
146 | static void inline __read_lock(rwlock_t *lock) | 155 | static void inline __read_lock(rwlock_t *lock) |
@@ -251,9 +260,12 @@ static int inline __write_trylock(rwlock_t *lock) | |||
251 | #else /* !(CONFIG_DEBUG_SPINLOCK) */ | 260 | #else /* !(CONFIG_DEBUG_SPINLOCK) */ |
252 | 261 | ||
253 | typedef struct { | 262 | typedef struct { |
254 | unsigned long lock; | 263 | volatile unsigned long lock; |
255 | unsigned int writer_pc, writer_cpu; | 264 | unsigned int writer_pc, writer_cpu; |
256 | unsigned int reader_pc[NR_CPUS]; | 265 | unsigned int reader_pc[NR_CPUS]; |
266 | #ifdef CONFIG_PREEMPT | ||
267 | unsigned int break_lock; | ||
268 | #endif | ||
257 | } rwlock_t; | 269 | } rwlock_t; |
258 | #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0xff, { } } | 270 | #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0xff, { } } |
259 | #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) | 271 | #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) |
@@ -304,6 +316,8 @@ do { unsigned long flags; \ | |||
304 | #endif /* CONFIG_DEBUG_SPINLOCK */ | 316 | #endif /* CONFIG_DEBUG_SPINLOCK */ |
305 | 317 | ||
306 | #define _raw_read_trylock(lock) generic_raw_read_trylock(lock) | 318 | #define _raw_read_trylock(lock) generic_raw_read_trylock(lock) |
319 | #define read_can_lock(rw) (!((rw)->lock & 0x80000000UL)) | ||
320 | #define write_can_lock(rw) (!(rw)->lock) | ||
307 | 321 | ||
308 | #endif /* !(__ASSEMBLY__) */ | 322 | #endif /* !(__ASSEMBLY__) */ |
309 | 323 | ||