rework langinfo code for ABI compat and for use by time code
[musl] / src / thread / __lock.c
index 21cb71a..2f345ae 100644 (file)
@@ -2,10 +2,11 @@
 
 void __lock(volatile int *l)
 {
-       int spins=100000;
-       /* Do not use futexes because we insist that unlocking is a simple
-        * assignment to optimize non-pathological code with no contention. */
-       while (a_xchg(l, 1))
-               if (spins) spins--, a_spin();
-               else __syscall(__NR_sched_yield);
+       while (a_swap(l, 1)) __wait(l, l+1, 1, 1);
+}
+
+void __unlock(volatile int *l)
+{
+       a_store(l, 0);
+       if (l[1]) __wake(l, 1, 1);
 }