with this patch, the syscallN() functions are no longer needed; a variadic syscall() macro allows syscalls with anywhere from 0 to 6 arguments to be made with a single macro name. also, manually casting each non-integer argument with (long) is no longer necessary; the casts are hidden in the macros. some source files which depended on being able to define the old macro SYSCALL_RETURNS_ERRNO have been modified to directly use __syscall() instead of syscall(). references to SYSCALL_SIGSET_SIZE and SYSCALL_LL have also been changed. x86_64 has not been tested, and may need a follow-up commit to fix any minor bugs/oversights.
15 lines
361 B
C
15 lines
361 B
C
#include "pthread_impl.h"
|
|
|
|
void __wait(volatile int *addr, volatile int *waiters, int val, int priv)
|
|
{
|
|
int spins=50000;
|
|
if (priv) priv = 128; priv=0;
|
|
while (spins--) {
|
|
if (*addr==val) a_spin();
|
|
else return;
|
|
}
|
|
if (waiters) a_inc(waiters);
|
|
while (*addr==val)
|
|
__syscall(__NR_futex, (long)addr, FUTEX_WAIT|priv, val, 0);
|
|
if (waiters) a_dec(waiters);
|
|
}
|