summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/thread/pthread_spin_lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-top-half/musl/src/thread/pthread_spin_lock.c')
-rw-r--r--libc-top-half/musl/src/thread/pthread_spin_lock.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/thread/pthread_spin_lock.c b/libc-top-half/musl/src/thread/pthread_spin_lock.c
new file mode 100644
index 0000000..ded2b65
--- /dev/null
+++ b/libc-top-half/musl/src/thread/pthread_spin_lock.c
@@ -0,0 +1,8 @@
+#include "pthread_impl.h"
+#include <errno.h>
+
+int pthread_spin_lock(pthread_spinlock_t *s)
+{
+ while (*(volatile int *)s || a_cas(s, 0, EBUSY)) a_spin();
+ return 0;
+}