diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-01-31 15:49:28 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-01-31 15:49:28 -0500 |
commit | 638e174688f58200d0deb7435093435e7d737b09 (patch) | |
tree | a2cd32dbb41daf0a5d4e69eff1805fd5574c292a /include/asm-sparc64/spinlock.h | |
parent | 8d58d773b745950ac912e028b3c81f4902fbf91d (diff) | |
parent | d195ea4b1456192abe780fd773778cbe9f6d77ea (diff) |
Merge branch 'origin'
Diffstat (limited to 'include/asm-sparc64/spinlock.h')
-rw-r--r-- | include/asm-sparc64/spinlock.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/include/asm-sparc64/spinlock.h b/include/asm-sparc64/spinlock.h index ec85d12d73b9..508c416e9d6a 100644 --- a/include/asm-sparc64/spinlock.h +++ b/include/asm-sparc64/spinlock.h | |||
@@ -131,6 +131,28 @@ static void inline __read_lock(raw_rwlock_t *lock) | |||
131 | : "memory"); | 131 | : "memory"); |
132 | } | 132 | } |
133 | 133 | ||
134 | static int inline __read_trylock(raw_rwlock_t *lock) | ||
135 | { | ||
136 | int tmp1, tmp2; | ||
137 | |||
138 | __asm__ __volatile__ ( | ||
139 | "1: ldsw [%2], %0\n" | ||
140 | " brlz,a,pn %0, 2f\n" | ||
141 | " mov 0, %0\n" | ||
142 | " add %0, 1, %1\n" | ||
143 | " cas [%2], %0, %1\n" | ||
144 | " cmp %0, %1\n" | ||
145 | " membar #StoreLoad | #StoreStore\n" | ||
146 | " bne,pn %%icc, 1b\n" | ||
147 | " mov 1, %0\n" | ||
148 | "2:" | ||
149 | : "=&r" (tmp1), "=&r" (tmp2) | ||
150 | : "r" (lock) | ||
151 | : "memory"); | ||
152 | |||
153 | return tmp1; | ||
154 | } | ||
155 | |||
134 | static void inline __read_unlock(raw_rwlock_t *lock) | 156 | static void inline __read_unlock(raw_rwlock_t *lock) |
135 | { | 157 | { |
136 | unsigned long tmp1, tmp2; | 158 | unsigned long tmp1, tmp2; |
@@ -211,12 +233,12 @@ static int inline __write_trylock(raw_rwlock_t *lock) | |||
211 | } | 233 | } |
212 | 234 | ||
213 | #define __raw_read_lock(p) __read_lock(p) | 235 | #define __raw_read_lock(p) __read_lock(p) |
236 | #define __raw_read_trylock(p) __read_trylock(p) | ||
214 | #define __raw_read_unlock(p) __read_unlock(p) | 237 | #define __raw_read_unlock(p) __read_unlock(p) |
215 | #define __raw_write_lock(p) __write_lock(p) | 238 | #define __raw_write_lock(p) __write_lock(p) |
216 | #define __raw_write_unlock(p) __write_unlock(p) | 239 | #define __raw_write_unlock(p) __write_unlock(p) |
217 | #define __raw_write_trylock(p) __write_trylock(p) | 240 | #define __raw_write_trylock(p) __write_trylock(p) |
218 | 241 | ||
219 | #define __raw_read_trylock(lock) generic__raw_read_trylock(lock) | ||
220 | #define __raw_read_can_lock(rw) (!((rw)->lock & 0x80000000UL)) | 242 | #define __raw_read_can_lock(rw) (!((rw)->lock & 0x80000000UL)) |
221 | #define __raw_write_can_lock(rw) (!(rw)->lock) | 243 | #define __raw_write_can_lock(rw) (!(rw)->lock) |
222 | 244 | ||