Commit e24deaae authored by Eddie Kohler's avatar Eddie Kohler

Timestamps: Default to nanosecond-precision timestamps if clock_gettime()

is available.  Inspired by POSIX 2008 deprecating gettimeofday().
parent 731e87f0
......@@ -7412,16 +7412,6 @@ done
# Check whether --enable-nanotimestamp was given.
if test "${enable_nanotimestamp+set}" = set; then :
enableval=$enable_nanotimestamp;
fi
if test "x$enable_nanotimestamp" = xyes; then
$as_echo "#define HAVE_NANOTIMESTAMP_ENABLED 1" >>confdefs.h
fi
for ac_header in time.h
do :
ac_fn_cxx_check_header_mongrel "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default"
......@@ -7517,6 +7507,7 @@ _ACEOF
fi
have_clock_gettime=no
ac_fn_cxx_check_decl "$LINENO" "clock_gettime" "ac_cv_have_decl_clock_gettime" "#ifdef HAVE_TIME_H
# include <time.h>
#endif
......@@ -7588,6 +7579,7 @@ if test "$ac_res" != no; then :
$as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
have_clock_gettime=yes
fi
POSIX_CLOCK_LIBS="$LIBS"
......@@ -7595,6 +7587,21 @@ fi
LIBS="$SAVELIBS"
# Check whether --enable-nanotimestamp was given.
if test "${enable_nanotimestamp+set}" = set; then :
enableval=$enable_nanotimestamp;
fi
# Default to nanosecond-precision timestamps if clock_gettime is available.
if test "x$enable_nanotimestamp" = x -a "x$have_clock_gettime" = xyes; then
enable_nanotimestamp=yes
fi
if test "x$enable_nanotimestamp" = xyes; then
$as_echo "#define HAVE_NANOTIMESTAMP_ENABLED 1" >>confdefs.h
fi
# Check whether --enable-tools was given.
......
......@@ -437,11 +437,6 @@ dnl
dnl timestamps
dnl
AC_ARG_ENABLE(nanotimestamp, [ --enable-nanotimestamp enable nanosecond timestamps])
if test "x$enable_nanotimestamp" = xyes; then
AC_DEFINE(HAVE_NANOTIMESTAMP_ENABLED)
fi
AC_CHECK_HEADERS(time.h)
AC_CHECK_SIZEOF([struct timeval])
AC_CHECK_TYPES([struct timespec], have_timespec=yes, have_timespec=no)
......@@ -450,6 +445,15 @@ if test "x$have_timespec" = xyes; then
fi
CLICK_CHECK_POSIX_CLOCKS
AC_ARG_ENABLE(nanotimestamp, [ --enable-nanotimestamp enable nanosecond timestamps])
# Default to nanosecond-precision timestamps if clock_gettime is available.
if test "x$enable_nanotimestamp" = x -a "x$have_clock_gettime" = xyes; then
enable_nanotimestamp=yes
fi
if test "x$enable_nanotimestamp" = xyes; then
AC_DEFINE([HAVE_NANOTIMESTAMP_ENABLED], [1], [Define if nanosecond-granularity timestamps are enabled.])
fi
dnl
dnl check whether tools should be built for host or build
......
......@@ -797,12 +797,14 @@ dnl POSIX_CLOCK_LIBS.
dnl
AC_DEFUN([CLICK_CHECK_POSIX_CLOCKS], [
have_clock_gettime=no
AC_CHECK_DECLS([clock_gettime], [], [], [#ifdef HAVE_TIME_H
# include <time.h>
#endif])
SAVELIBS="$LIBS"
AC_SEARCH_LIBS([clock_gettime], [rt],
[AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define if you have the clock_gettime function.])])
[AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define if you have the clock_gettime function.])
have_clock_gettime=yes])
POSIX_CLOCK_LIBS="$LIBS"
AC_SUBST(POSIX_CLOCK_LIBS)
LIBS="$SAVELIBS"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment