configure.ac: check for clock_gettime and CLOCK_MONOTONIC
Set or clear Makefile variables HAVE_CLOCK_GETTIME and HAVE_CLOCK_MONOTONIC based upon results of the checks (overriding default values from config.mak.uname). CLOCK_MONOTONIC isn't available on RHEL3, but there are still RHEL3 systems being used in production. Signed-off-by: Reuben Hawkins <reubenhwk@gmail.com> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Reuben Hawkins committed
Jan 8, 2015 at 12:00 UTC
a6c3c638acea34116c6be7cc4be41a9bc55a7fa1
4 files changed
+30
-1
Makefile
+6
@@ -343,6 +343,8 @@ all::
343
# return NULL when it receives a bogus time_t.
344
#
345
# Define HAVE_CLOCK_GETTIME if your platform has clock_gettime in librt.
346
+#
347
+# Define HAVE_CLOCK_MONOTONIC if your platform has CLOCK_MONOTONIC in librt.
348
349
GIT-VERSION-FILE: FORCE
350
@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1402,6 +1404,10 @@ ifdef HAVE_CLOCK_GETTIME
1404
EXTLIBS += -lrt
1405
endif
1406
1407
+ifdef HAVE_CLOCK_MONOTONIC
1408
+ BASIC_CFLAGS += -DHAVE_CLOCK_MONOTONIC
1409
+endif
1410
+
1411
ifeq ($(TCLTK_PATH),)
1412
NO_TCLTK = NoThanks
1413
endif
config.mak.uname
+1
@@ -35,6 +35,7 @@ ifeq ($(uname_S),Linux)
35
LIBC_CONTAINS_LIBINTL = YesPlease
36
HAVE_DEV_TTY = YesPlease
37
HAVE_CLOCK_GETTIME = YesPlease
38
+ HAVE_CLOCK_MONOTONIC = YesPlease
39
endif
40
ifeq ($(uname_S),GNU/kFreeBSD)
41
HAVE_ALLOCA_H = YesPlease
configure.ac
+22
@@ -947,6 +947,28 @@ AC_CHECK_LIB([iconv], [locale_charset],
947
[CHARSET_LIB=-lcharset])])
948
GIT_CONF_SUBST([CHARSET_LIB])
949
#
950
+# Define HAVE_CLOCK_GETTIME=YesPlease if clock_gettime is available.
951
+GIT_CHECK_FUNC(clock_gettime,
952
+ [HAVE_CLOCK_GETTIME=YesPlease],
953
+ [HAVE_CLOCK_GETTIME=])
954
+GIT_CONF_SUBST([HAVE_CLOCK_GETTIME])
955
+
956
+AC_DEFUN([CLOCK_MONOTONIC_SRC], [
957
+AC_LANG_PROGRAM([[
958
+#include <time.h>
959
+clockid_t id = CLOCK_MONOTONIC;
960
+]])])
961
+
962
+#
963
+# Define HAVE_CLOCK_MONOTONIC=YesPlease if CLOCK_MONOTONIC is available.
964
+AC_MSG_CHECKING([for CLOCK_MONOTONIC])
965
+AC_COMPILE_IFELSE([CLOCK_MONOTONIC_SRC],
966
+ [AC_MSG_RESULT([yes])
967
+ HAVE_CLOCK_MONOTONIC=YesPlease],
968
+ [AC_MSG_RESULT([no])
969
+ HAVE_CLOCK_MONOTONIC=])
970
+GIT_CONF_SUBST([HAVE_CLOCK_MONOTONIC])
971
+#
972
# Define NO_SETITIMER if you don't have setitimer.
973
GIT_CHECK_FUNC(setitimer,
974
[NO_SETITIMER=],
trace.c
+1
-1
@@ -322,7 +322,7 @@ int trace_want(struct trace_key *key)
322
return !!get_trace_fd(key);
323
}
324
325
-#ifdef HAVE_CLOCK_GETTIME
325
+#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CLOCK_MONOTONIC)
326
327
static inline uint64_t highres_nanos(void)
328
{