From b8b85a42729dc96e43d51848823fbe28ad92b5c0 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Thu, 24 Mar 2011 23:06:08 -0400
Subject: optimize contended case for pthread_spin_trylock

---
 src/thread/pthread_spin_trylock.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/thread/pthread_spin_trylock.c b/src/thread/pthread_spin_trylock.c
index c12696b3..1fc5f73c 100644
--- a/src/thread/pthread_spin_trylock.c
+++ b/src/thread/pthread_spin_trylock.c
@@ -2,5 +2,6 @@
 
 int pthread_spin_trylock(pthread_spinlock_t *s)
 {
-	return -a_xchg(s, 1) & EBUSY;
+	if (*s || a_xchg(s, 1)) return EBUSY;
+	return 0;
 }
-- 
cgit v1.2.3-70-g09d2