From 1ee46520caa1a2a47c69d58f49f4042194ec0339 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 29 May 2014 10:27:55 -0700 Subject: [PATCH] Return the actual success result from __futex. futex(2) can return non-zero successes. Bug: 15195455 Change-Id: I7818bc922a5a2df31228ff72c169320b5e69a544 --- libc/private/bionic_futex.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libc/private/bionic_futex.h b/libc/private/bionic_futex.h index 35d33d0bf..bd2bd369c 100644 --- a/libc/private/bionic_futex.h +++ b/libc/private/bionic_futex.h @@ -42,12 +42,12 @@ struct timespec; static inline __always_inline int __futex(volatile void* ftx, int op, int value, const struct timespec* timeout) { // Our generated syscall assembler sets errno, but our callers (pthread functions) don't want to. int saved_errno = errno; - if (__predict_false(syscall(__NR_futex, ftx, op, value, timeout) == -1)) { - int result = -errno; + int result = syscall(__NR_futex, ftx, op, value, timeout); + if (__predict_false(result == -1)) { + result = -errno; errno = saved_errno; - return result; } - return 0; + return result; } static inline int __futex_wake(volatile void* ftx, int count) {