1 #include "pthread_impl.h"
2
__wait(volatile int * addr,volatile int * waiters,int val,int priv)3 void __wait(volatile int *addr, volatile int *waiters, int val, int priv)
4 {
5 int spins=100;
6 if (priv) priv = FUTEX_PRIVATE;
7 while (spins-- && (!waiters || !*waiters)) {
8 if (*addr==val) a_spin();
9 else return;
10 }
11 if (waiters) a_inc(waiters);
12 while (*addr==val) {
13 __syscall(SYS_futex, addr, FUTEX_WAIT|priv, val, 0) != -ENOSYS
14 || __syscall(SYS_futex, addr, FUTEX_WAIT, val, 0);
15 }
16 if (waiters) a_dec(waiters);
17 }
18