about summary refs log tree commit diff
path: root/src/thread/pthread_spin_trylock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread/pthread_spin_trylock.c')
-rw-r--r--src/thread/pthread_spin_trylock.c3
1 files changed, 2 insertions, 1 deletions
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;
 }