Don't use POSIX semaphores if a MONOTONIC clock is available

POSIX semaphores use CLOCK_REALTIME, but our semaphore_t abstraction
expects CLOCK_MONOTONIC based times. Use the mutex/condvar based
fallback if time_monotonic() actuall returns monotonic times.
This commit is contained in:
Martin Willi 2012-08-20 17:58:58 +02:00
parent 10bdc7a968
commit 88a5abf5e2
1 changed files with 8 additions and 0 deletions

View File

@ -15,6 +15,14 @@
#include <library.h>
#if defined(HAVE_CLOCK_GETTIME) && \
(defined(HAVE_CONDATTR_CLOCK_MONOTONIC) || \
defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC))
/* if we use MONOTONIC times, we can't use POSIX_SEMAPHORES since they use
* times based on CLOCK_REALTIME */
#undef HAVE_SEM_TIMEDWAIT
#endif /* HAVE_CLOCK_GETTIME && ... */
#ifdef HAVE_SEM_TIMEDWAIT
#include <semaphore.h>
#else /* !HAVE_SEM_TIMEDWAIT */