mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-16 19:54:38 +01:00
fixed GH #1403: Android compile with poco-1.7.5 no 'pthread_condattr_setclock' error
This commit is contained in:
parent
80fea48cdc
commit
29010bc6ad
@ -24,6 +24,19 @@
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Note: pthread_cond_timedwait() with CLOCK_MONOTONIC is supported
|
||||
// on Linux and QNX, as well as on Android >= 5.0. On Android < 5.0,
|
||||
// HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC is defined to indicate
|
||||
// availability of non-standard pthread_cond_timedwait_monotonic().
|
||||
//
|
||||
#ifndef POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT
|
||||
#if (defined(__linux__) || defined(__QNX__)) && !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC))
|
||||
#define POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
@ -40,7 +53,7 @@ EventImpl::EventImpl(EventTypeImpl type): _auto(type == EVENT_AUTORESET_IMPL), _
|
||||
if (pthread_mutex_init(&_mutex, NULL))
|
||||
throw SystemException("cannot create event (mutex)");
|
||||
|
||||
#if defined(__linux__) || defined(__QNX__)
|
||||
#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
|
||||
pthread_condattr_t attr;
|
||||
if (pthread_condattr_init(&attr))
|
||||
{
|
||||
@ -105,7 +118,7 @@ bool EventImpl::waitImpl(long milliseconds)
|
||||
delta.tv_sec = milliseconds / 1000;
|
||||
delta.tv_nsec = (milliseconds % 1000)*1000000;
|
||||
pthread_get_expiration_np(&delta, &abstime);
|
||||
#elif defined(__linux__) || defined(__QNX__)
|
||||
#elif defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
|
||||
clock_gettime(CLOCK_MONOTONIC, &abstime);
|
||||
abstime.tv_sec += milliseconds / 1000;
|
||||
abstime.tv_nsec += (milliseconds % 1000)*1000000;
|
||||
|
@ -24,6 +24,19 @@
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Note: pthread_cond_timedwait() with CLOCK_MONOTONIC is supported
|
||||
// on Linux and QNX, as well as on Android >= 5.0. On Android < 5.0,
|
||||
// HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC is defined to indicate
|
||||
// availability of non-standard pthread_cond_timedwait_monotonic().
|
||||
//
|
||||
#ifndef POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT
|
||||
#if (defined(__linux__) || defined(__QNX__)) && !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC))
|
||||
#define POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
@ -41,7 +54,7 @@ SemaphoreImpl::SemaphoreImpl(int n, int max): _n(n), _max(max)
|
||||
if (pthread_mutex_init(&_mutex, NULL))
|
||||
throw SystemException("cannot create semaphore (mutex)");
|
||||
|
||||
#if defined(__linux__) || defined(__QNX__)
|
||||
#if defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
|
||||
pthread_condattr_t attr;
|
||||
if (pthread_condattr_init(&attr))
|
||||
{
|
||||
@ -105,7 +118,7 @@ bool SemaphoreImpl::waitImpl(long milliseconds)
|
||||
delta.tv_sec = milliseconds / 1000;
|
||||
delta.tv_nsec = (milliseconds % 1000)*1000000;
|
||||
pthread_get_expiration_np(&delta, &abstime);
|
||||
#elif defined(__linux__) || defined(__QNX__)
|
||||
#elif defined(POCO_HAVE_MONOTONIC_PTHREAD_COND_TIMEDWAIT)
|
||||
clock_gettime(CLOCK_MONOTONIC, &abstime);
|
||||
abstime.tv_sec += milliseconds / 1000;
|
||||
abstime.tv_nsec += (milliseconds % 1000)*1000000;
|
||||
|
Loading…
Reference in New Issue
Block a user