From: Rich Felker Date: Sat, 23 Aug 2014 03:49:54 +0000 (-0400) Subject: fix fallback checks for kernels without private futex support X-Git-Tag: v1.1.5~55 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b8ca9eb5301580dcf101753451eee196edceefbd;p=oweals%2Fmusl.git fix fallback checks for kernels without private futex support for unknown syscall commands, the kernel produces ENOSYS, not EINVAL. --- diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h index 2d090f8f..4de66378 100644 --- a/src/internal/pthread_impl.h +++ b/src/internal/pthread_impl.h @@ -112,7 +112,7 @@ static inline void __wake(volatile void *addr, int cnt, int priv) { if (priv) priv = 128; if (cnt<0) cnt = INT_MAX; - __syscall(SYS_futex, addr, FUTEX_WAKE|priv, cnt) != -EINVAL || + __syscall(SYS_futex, addr, FUTEX_WAKE|priv, cnt) != -ENOSYS || __syscall(SYS_futex, addr, FUTEX_WAKE, cnt); } diff --git a/src/thread/__timedwait.c b/src/thread/__timedwait.c index 39eb9963..d6f12331 100644 --- a/src/thread/__timedwait.c +++ b/src/thread/__timedwait.c @@ -29,7 +29,7 @@ int __timedwait(volatile int *addr, int val, pthread_cleanup_push(cleanup, arg); r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT|priv, val, top); - if (r == EINVAL) r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT, val, top); + if (r == ENOSYS) r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT, val, top); if (r != EINTR && r != ETIMEDOUT) r = 0; pthread_cleanup_pop(0); diff --git a/src/thread/__wait.c b/src/thread/__wait.c index ec1e8206..3d0d9204 100644 --- a/src/thread/__wait.c +++ b/src/thread/__wait.c @@ -10,7 +10,7 @@ void __wait(volatile int *addr, volatile int *waiters, int val, int priv) } if (waiters) a_inc(waiters); while (*addr==val) { - __syscall(SYS_futex, addr, FUTEX_WAIT|priv, val, 0) != -EINVAL + __syscall(SYS_futex, addr, FUTEX_WAIT|priv, val, 0) != -ENOSYS || __syscall(SYS_futex, addr, FUTEX_WAIT, val, 0); } if (waiters) a_dec(waiters); diff --git a/src/thread/pthread_barrier_wait.c b/src/thread/pthread_barrier_wait.c index 6b329c95..4a964fe3 100644 --- a/src/thread/pthread_barrier_wait.c +++ b/src/thread/pthread_barrier_wait.c @@ -87,7 +87,7 @@ int pthread_barrier_wait(pthread_barrier_t *b) a_spin(); a_inc(&inst->finished); while (inst->finished == 1) - __syscall(SYS_futex,&inst->finished,FUTEX_WAIT|128,1,0) != -EINTR + __syscall(SYS_futex,&inst->finished,FUTEX_WAIT|128,1,0) != -ENOSYS || __syscall(SYS_futex,&inst->finished,FUTEX_WAIT,1,0); return PTHREAD_BARRIER_SERIAL_THREAD; } diff --git a/src/thread/pthread_cond_timedwait.c b/src/thread/pthread_cond_timedwait.c index c5cf66c3..2d192b07 100644 --- a/src/thread/pthread_cond_timedwait.c +++ b/src/thread/pthread_cond_timedwait.c @@ -52,7 +52,7 @@ static inline void unlock_requeue(volatile int *l, volatile int *r, int w) { a_store(l, 0); if (w) __wake(l, 1, 1); - else __syscall(SYS_futex, l, FUTEX_REQUEUE|128, 0, 1, r) != -EINVAL + else __syscall(SYS_futex, l, FUTEX_REQUEUE|128, 0, 1, r) != -ENOSYS || __syscall(SYS_futex, l, FUTEX_REQUEUE, 0, 1, r); }