lift child restrictions after multi-threaded fork
[musl.git] / src / thread / vmlock.c
blobfa0a8e3c2ed631572834329ba30ce76c4c4b2364
1 #include "pthread_impl.h"
2 #include "fork_impl.h"
4 static volatile int vmlock[2];
5 volatile int *const __vmlock_lockptr = vmlock;
7 void __vm_wait()
9 int tmp;
10 while ((tmp=vmlock[0]))
11 __wait(vmlock, vmlock+1, tmp, 1);
14 void __vm_lock()
16 a_inc(vmlock);
19 void __vm_unlock()
21 if (a_fetch_add(vmlock, -1)==1 && vmlock[1])
22 __wake(vmlock, -1, 1);