fix fallback checks for kernels without private futex support
authorRich Felker <dalias@aerifal.cx>
Sat, 23 Aug 2014 03:49:54 +0000 (23:49 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 23 Aug 2014 03:49:54 +0000 (23:49 -0400)
for unknown syscall commands, the kernel produces ENOSYS, not EINVAL.

src/internal/pthread_impl.h
src/thread/__timedwait.c
src/thread/__wait.c
src/thread/pthread_barrier_wait.c
src/thread/pthread_cond_timedwait.c

index 2d090f8f6e2199288d3d2382cb3088c9b464353f..4de663785c0473efc38446f17a9f7fa36981b197 100644 (file)
@@ -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);
 }
 
index 39eb9963e7e1e055076d6a5d8efbcc46e748e90b..d6f1233173b30fda19f2c10dcd10c310454ddbd5 100644 (file)
@@ -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);
index ec1e82064a44f6299e4eb543318875af35912aff..3d0d92044fda8dfd610e7b203bffbfe722dfc5c7 100644 (file)
@@ -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);
index 6b329c9579ca55507874c64237b9a74e89d995dd..4a964fe3de2344cb37d974a8bf955b61a4266d6c 100644 (file)
@@ -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;
        }
index c5cf66c35b28f135f54222a0b105b76cb25fec6c..2d192b07396ac9e32e69c95b3d6a539bc5b78f31 100644 (file)
@@ -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);
 }