Use pthread_cond_timedwait_monotonic on Android.
This commit is contained in:
@@ -304,6 +304,8 @@ AC_TRY_RUN(
|
|||||||
)
|
)
|
||||||
dnl check if we actually are able to configure attributes on cond vars
|
dnl check if we actually are able to configure attributes on cond vars
|
||||||
AC_CHECK_FUNCS(pthread_condattr_init)
|
AC_CHECK_FUNCS(pthread_condattr_init)
|
||||||
|
dnl instead of pthread_condattr_setclock Android has this function
|
||||||
|
AC_CHECK_FUNCS(pthread_cond_timedwait_monotonic)
|
||||||
dnl check if native rwlocks are available
|
dnl check if native rwlocks are available
|
||||||
AC_CHECK_FUNCS(pthread_rwlock_init)
|
AC_CHECK_FUNCS(pthread_rwlock_init)
|
||||||
LIBS=$saved_LIBS
|
LIBS=$saved_LIBS
|
||||||
|
|||||||
@@ -253,6 +253,11 @@ static void _wait(private_condvar_t *this, private_mutex_t *mutex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* use the monotonic clock based version of this function if available */
|
||||||
|
#ifdef HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC
|
||||||
|
#define pthread_cond_timedwait pthread_cond_timedwait_monotonic
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of condvar_t.timed_wait_abs.
|
* Implementation of condvar_t.timed_wait_abs.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -167,7 +167,9 @@ bool mkdir_p(const char *path, mode_t mode)
|
|||||||
*/
|
*/
|
||||||
time_t time_monotonic(timeval_t *tv)
|
time_t time_monotonic(timeval_t *tv)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CONDATTR_CLOCK_MONOTONIC)
|
#if defined(HAVE_CLOCK_GETTIME) && \
|
||||||
|
(defined(HAVE_CONDATTR_CLOCK_MONOTONIC) || \
|
||||||
|
defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC))
|
||||||
/* as we use time_monotonic() for condvar operations, we use the
|
/* as we use time_monotonic() for condvar operations, we use the
|
||||||
* monotonic time source only if it is also supported by pthread. */
|
* monotonic time source only if it is also supported by pthread. */
|
||||||
timespec_t ts;
|
timespec_t ts;
|
||||||
@@ -181,7 +183,7 @@ time_t time_monotonic(timeval_t *tv)
|
|||||||
}
|
}
|
||||||
return ts.tv_sec;
|
return ts.tv_sec;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_CLOCK_MONOTONIC && HAVE_CONDATTR_CLOCK_MONOTONIC */
|
#endif /* HAVE_CLOCK_GETTIME && (...) */
|
||||||
/* Fallback to non-monotonic timestamps:
|
/* Fallback to non-monotonic timestamps:
|
||||||
* On MAC OS X, creating monotonic timestamps is rather difficult. We
|
* On MAC OS X, creating monotonic timestamps is rather difficult. We
|
||||||
* could use mach_absolute_time() and catch sleep/wakeup notifications.
|
* could use mach_absolute_time() and catch sleep/wakeup notifications.
|
||||||
|
|||||||
Reference in New Issue
Block a user