From 3bff1171e661bfbb3a53bda202a7a43f6fff4e20 Mon Sep 17 00:00:00 2001 From: Thomas Habets Date: Sun, 5 Sep 2010 00:30:46 +0200 Subject: Use monotonic clock to time out waiting for a reply If clock_gettime(CLOCK_MONOTONIC,) is supported then use that and all should be well. If it's not then at least work around hanging until next ping. --- configure.ac | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 2b42253..e653723 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,7 @@ AC_CHECK_LIB([net], [libnet_name_resolve], [AC_MSG_ERROR([libnet 1.0.x found. Arping 2.x requires libnet 1.1.x])]) AC_CHECK_LIB([net], [libnet_init], ,[AC_MSG_ERROR([libnet 1.1.x not found])]) AC_CHECK_LIB([pcap], [pcap_open_live], ,[AC_MSG_ERROR([libpcap not found])]) +AC_SEARCH_LIBS([clock_gettime], [rt]) # Checks for header files. AC_HEADER_STDC @@ -30,6 +31,7 @@ arpa/inet.h \ netinet/in.h \ stdlib.h \ sys/socket.h \ +time.h \ sys/time.h \ sys/types.h \ stdint.h \ @@ -70,6 +72,29 @@ case "$target_os" in AC_LIBOBJ([findif_other]) ;; esac + + + +# check for CLOCK_MONOTONIC +AC_CACHE_CHECK([for CLOCK_MONOTONIC], + ac_cv_have_clock_monotonic, [ + AC_TRY_RUN( + [ +#include +int main() { +struct timespec ts; +exit(!!clock_gettime(CLOCK_MONOTONIC, &ts)); +} + ], + [ ac_cv_have_clock_monotonic="yes" ], + [ ac_cv_have_clock_monotonic="no" ] + ) +]) +AM_CONDITIONAL(HAVE_CLOCK_MONOTONIC, test x$ac_cv_have_clock_monotonic = xyes) +if test x$ac_cv_have_clock_monotonic = xyes; then + AC_DEFINE([HAVE_CLOCK_MONOTONIC], [1], [Monotonic clock]) +fi + AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([src/Makefile]) AC_CONFIG_FILES([doc/Makefile]) -- cgit v1.2.1