aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sparc64
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-01-24 00:03:56 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-01-24 00:03:56 -0500
commitd3ed309a718bc6f79dc485a6d18731990daeee5e (patch)
treede908eec9cff81303038b0523169027748f38fa0 /include/asm-sparc64
parent4415863773eb0eeceba7318238ec0f63b0b5847a (diff)
[SPARC64]: Implement __raw_read_trylock()
generic__raw_read_trylock() just does a raw_read_lock() so that isn't very useful. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/asm-sparc64')
-rw-r--r--include/asm-sparc64/spinlock.h24
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
134static 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
134static void inline __read_unlock(raw_rwlock_t *lock) 156static 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