From bd3a98c6b9850a8e55fb0e0ed9f045212c494881 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Sat, 24 May 2014 17:19:36 -0700 Subject: [PATCH] Restore __futex_wake and __futex_wait for LP32. Should fix Skype: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__futex_wake" referenced by "libsliq.so"... Bug: 15196718 Change-Id: I8a18e18d830f0436e820cbde577121bd92710803 --- libc/bionic/ndk_cruft.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp index 295418bc2..46cc1f0a4 100644 --- a/libc/bionic/ndk_cruft.cpp +++ b/libc/bionic/ndk_cruft.cpp @@ -31,10 +31,12 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -199,4 +201,25 @@ extern "C" int vfdprintf(int fd, const char* fmt, va_list ap) { return vdprintf(fd, fmt, ap); } +static 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 (syscall(__NR_futex, ftx, op, value, timeout) == 0) { + return 0; + } + int result = -errno; + errno = saved_errno; + return result; +} + +// This used to be in . +extern "C" int __futex_wake(volatile void* ftx, int count) { + return __futex(ftx, FUTEX_WAKE, count, NULL); +} + +// This used to be in . +extern "C" int __futex_wait(volatile void* ftx, int value, const struct timespec* timeout) { + return __futex(ftx, FUTEX_WAIT, value, timeout); +} + #endif