[IA64] Define an ia64 version of __raw_read_trylock
authorKeith Owens <kaos@sgi.com>
Sat, 10 Dec 2005 03:24:28 +0000 (14:24 +1100)
committerTony Luck <tony.luck@intel.com>
Mon, 12 Dec 2005 16:54:18 +0000 (08:54 -0800)
IA64 is using the generic version of __raw_read_trylock, which always
waits for the lock to be free instead of returning when the lock is in
use.  Define an ia64 version of __raw_read_trylock which behaves
correctly, and drop the generic one.

Signed-off-by: Keith Owens <kaos@sgi.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
include/asm-ia64/spinlock.h

index 5b78611411c30e244a650b230aaae7c62ec5a6e9..0c91a76c5ea3cff8decee9debe0cf45d696a83c7 100644 (file)
@@ -201,6 +201,16 @@ static inline void __raw_write_unlock(raw_rwlock_t *x)
 
 #endif /* !ASM_SUPPORTED */
 
-#define __raw_read_trylock(lock) generic__raw_read_trylock(lock)
+static inline int __raw_read_trylock(raw_rwlock_t *x)
+{
+       union {
+               raw_rwlock_t lock;
+               __u32 word;
+       } old, new;
+       old.lock = new.lock = *x;
+       old.lock.write_lock = new.lock.write_lock = 0;
+       ++new.lock.read_counter;
+       return (u32)ia64_cmpxchg4_acq((__u32 *)(x), new.word, old.word) == old.word;
+}
 
 #endif /*  _ASM_IA64_SPINLOCK_H */