Index: fusl/src/thread/__lock.c |
diff --git a/fusl/src/thread/__lock.c b/fusl/src/thread/__lock.c |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0874c04a4c0a81a9fa0dc032479ec18cec81d8aa |
--- /dev/null |
+++ b/fusl/src/thread/__lock.c |
@@ -0,0 +1,15 @@ |
+#include "pthread_impl.h" |
+ |
+void __lock(volatile int *l) |
+{ |
+ if (libc.threads_minus_1) |
+ while (a_swap(l, 1)) __wait(l, l+1, 1, 1); |
+} |
+ |
+void __unlock(volatile int *l) |
+{ |
+ if (l[0]) { |
+ a_store(l, 0); |
+ if (l[1]) __wake(l, 1, 1); |
+ } |
+} |