about summary refs log tree commit diff
path: root/src/thread
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/pthread_spin_lock.c2
-rw-r--r--src/thread/pthread_spin_trylock.c3
2 files changed, 2 insertions, 3 deletions
diff --git a/src/thread/pthread_spin_lock.c b/src/thread/pthread_spin_lock.c
index 59fa6ea8..0ab3d64f 100644
--- a/src/thread/pthread_spin_lock.c
+++ b/src/thread/pthread_spin_lock.c
@@ -2,6 +2,6 @@
 
 int pthread_spin_lock(pthread_spinlock_t *s)
 {
-	while (a_xchg(s, 1));
+	while (a_xchg(s, 1)) a_spin();
 	return 0;
 }
diff --git a/src/thread/pthread_spin_trylock.c b/src/thread/pthread_spin_trylock.c
index 1fc5f73c..c12696b3 100644
--- a/src/thread/pthread_spin_trylock.c
+++ b/src/thread/pthread_spin_trylock.c
@@ -2,6 +2,5 @@
 
 int pthread_spin_trylock(pthread_spinlock_t *s)
 {
-	if (*s || a_xchg(s, 1)) return EBUSY;
-	return 0;
+	return -a_xchg(s, 1) & EBUSY;
 }