summaryrefslogtreecommitdiffstats
path: root/configure.in
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2009-07-10 22:27:55 -0400
committerColin Walters <walters@verbum.org>2009-07-14 15:40:24 -0400
commit2e286c8a27f30a5eb4933a84754e1c8059ec3805 (patch)
tree2b6dfefeeae7c3ef5a31aba71bcf95f133e72877 /configure.in
parent943b9d3944a507d106613dbf3fa678c6a0bcbade (diff)
Bug 18121 - Use a monotonic clock for pthread timeouts
Patch based on one from Keith Mok <ek9852@gmail.com>, some followup work from Janne Karhunen <Janne.Karhunen@gmail.com>. We don't want condition variable timeouts to be affected by the system clock. Use the POSIX CLOCK_MONOTONIC if available. (cherry picked from commit ae24bb35e2ee3ecde990f55852982b573754ec43)
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in25
1 files changed, 24 insertions, 1 deletions
diff --git a/configure.in b/configure.in
index bba68d14..f02089ed 100644
--- a/configure.in
+++ b/configure.in
@@ -696,8 +696,31 @@ if $dbus_use_libxml; then
fi
# Thread lib detection
-AC_CHECK_FUNC(pthread_cond_timedwait,,[AC_CHECK_LIB(pthread,pthread_cond_timedwait,
+AC_CHECK_FUNC(pthread_cond_timedwait,[AC_CHECK_LIB(pthread,pthread_cond_timedwait,
[THREAD_LIBS="-lpthread"])])
+save_libs="$LIBS"
+LIBS="$LIBS $THREAD_LIBS"
+AC_CHECK_FUNC(pthread_condattr_setclock,have_pthread_condattr_setclock=true,have_pthread_condattr_setclock=false)
+if test x$have_pthread_condattr_setclock = xtrue; then
+ AC_SEARCH_LIBS([clock_getres],[rt],[THREAD_LIBS="$THREAD_LIBS -lrt"])
+ AC_MSG_CHECKING([for CLOCK_MONOTONIC])
+ AC_TRY_COMPILE([#include <time.h>
+#include <pthread.h>
+], [
+struct timespec monotonic_timer;
+pthread_condattr_t attr;
+pthread_condattr_init (&attr);
+pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
+clock_getres (CLOCK_MONOTONIC,&monotonic_timer);
+], have_clock_monotonic=true, have_clock_monotonic=false)
+if test x$have_clock_monotonic = xtrue; then
+ AC_MSG_RESULT([found])
+ AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1, [Define if we have CLOCK_MONOTONIC])
+else
+ AC_MSG_RESULT([not found])
+fi
+fi
+LIBS="$save_libs"
# SELinux detection
if test x$enable_selinux = xno ; then