From b0facb55c48c1e84d1a855ea862d5381667effa3 Mon Sep 17 00:00:00 2001 From: John Hood Date: Thu, 29 Sep 2016 01:01:01 -0400 Subject: [PATCH] Test carefully for clock_gettime() and CLOCK_MONOTONIC --- configure.ac | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1360662..93278b5 100644 --- a/configure.ac +++ b/configure.ac @@ -180,6 +180,8 @@ AC_SEARCH_LIBS([compress], [z], , [AC_MSG_ERROR([Unable to find zlib.])]) AC_SEARCH_LIBS([socket], [socket]) AC_SEARCH_LIBS([inet_addr], [nsl]) +AC_SEARCH_LIBS([clock_gettime], [rt]) + # Checks for header files. AC_CHECK_HEADERS(m4_normalize([ fcntl.h @@ -256,8 +258,6 @@ AC_CHECK_FUNCS(m4_normalize([ pledge ])) -AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define if clock_gettime is available.])]) - # Start by trying to find the needed tinfo parts by pkg-config PKG_CHECK_MODULES([TINFO], [tinfo], [AC_DEFINE([HAVE_CURSES_H], [1], [Define to 1 if is present])], @@ -404,6 +404,15 @@ public: [AC_MSG_RESULT([no])]) AC_LANG_POP(C++) +AC_MSG_CHECKING([whether clock_gettime() is supported]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include +struct timespec ts; +]], [[return clock_gettime(CLOCK_MONOTONIC, &ts);]])], + [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], + [Define if clock_gettime() is available.]) + AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])]) + AC_CHECK_DECL([mach_absolute_time], [AC_DEFINE([HAVE_MACH_ABSOLUTE_TIME], [1], [Define if mach_absolute_time is available.])],