diff --git a/src/unix/thread.c b/src/unix/thread.c index c7ff3fa4..f8846225 100644 --- a/src/unix/thread.c +++ b/src/unix/thread.c @@ -618,7 +618,16 @@ 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_API__) && __ANDROID_API__ < 21 + + /* + * The bionic pthread implementation doesn't support CLOCK_MONOTONIC, + * but has this alternative function instead. + */ + r = pthread_cond_timedwait_monotonic_np(cond, mutex, &ts); +#else r = pthread_cond_timedwait(cond, mutex, &ts); +#endif /* __ANDROID_API__ */ #endif