summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.pp.se>2010-09-05 00:30:46 +0200
committerThomas Habets <thomas@habets.pp.se>2010-09-05 00:33:53 +0200
commit3bff1171e661bfbb3a53bda202a7a43f6fff4e20 (patch)
tree695eef42f332078b6b65661f1850857484ade788 /configure.ac
parent86112ba1232dda9ec8cc2bb57269ac2f4584e8cb (diff)
downloadarping-3bff1171e661bfbb3a53bda202a7a43f6fff4e20.tar.gz
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.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac25
1 files changed, 25 insertions, 0 deletions
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 <time.h>
+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])