From 3e75042a2b582c88c236c0807ac5c8e4623d2395 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Fri, 30 Jan 2015 13:10:47 +1100 Subject: [PATCH] unix: check Android support for pthread_cond_timedwait_monotonic_np MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since API level 21 (Android 5.0) the non-standard pthread function pthread_cond_timedwait_monotonic_np has been removed in favour of the standard pthread_cond_timedwait which libuv normally uses on Linux. This commit changes the detection of the Android OS to account for the removal of the function via the #define HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC which is only present in older API levels. Fixes: https://github.com/libuv/libuv/issues/172 PR-URL: https://github.com/libuv/libuv/pull/176 Reviewed-By: Saúl Ibarra Corretgé --- src/unix/thread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/thread.c b/src/unix/thread.c index 7a55bd63..7e85bcc5 100644 --- a/src/unix/thread.c +++ b/src/unix/thread.c @@ -330,7 +330,7 @@ int uv_cond_init(uv_cond_t* cond) { if (err) return -err; -#if !defined(__ANDROID__) +#if !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)) err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); if (err) goto error2; @@ -388,7 +388,7 @@ int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { timeout += uv__hrtime(UV_CLOCK_PRECISE); ts.tv_sec = timeout / NANOSEC; ts.tv_nsec = timeout % NANOSEC; -#if defined(__ANDROID__) +#if defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC) /* * The bionic pthread implementation doesn't support CLOCK_MONOTONIC, * but has this alternative function instead.