]> git.gsnw.org Git - fping.git/commitdiff
Move the OS detection to configure.ac script to set the use of clock_realtime
authorGerman Service Network <support@gsnw.de>
Sun, 10 Sep 2023 08:33:33 +0000 (10:33 +0200)
committerDavid Schweikert <david@schweikert.ch>
Thu, 2 Nov 2023 07:00:33 +0000 (08:00 +0100)
configure.ac
src/fping.c

index f75efd5b6529c0b1d60e46ee8f11c3e61b2b7f0e..fcc0787c99df608caba5ddac7c10f31a81765bd5 100644 (file)
@@ -7,6 +7,22 @@ AC_INIT([fping],[5.1])
 
 m4_ifdef([AC_AUTOCONF_VERSION],[AC_USE_SYSTEM_EXTENSIONS], [AC_GNU_SOURCE])
 
+# Detect Operatingsystem
+AC_CANONICAL_HOST
+only_clock_realtime=no
+
+case "${host_os}" in
+  darwin*)
+    only_clock_realtime=yes
+    ;;
+  *freebsd*)
+    only_clock_realtime=yes
+    ;;
+  *openbsd*)
+    only_clock_realtime=yes
+    ;;
+esac
+
 dnl --disable-ipv4
 AC_ARG_ENABLE([ipv4],
   AS_HELP_STRING([--disable-ipv4], [Disable support for pinging IPv4 hosts]))
@@ -44,6 +60,7 @@ dnl Test if --enable-timestamp is explicitely enabled and make an error if this
 AS_IF([test "x$enable_timestamp" = "xyes" -a "x$have_so_timestamp" = "xno"], [
   AC_MSG_ERROR([--enable-timestamp not supported on this platform])
 ])
+AS_IF([test "x$only_clock_realtime" = "xyes"], [AC_DEFINE(ONLY_CLOCK_REALTIME, [1], [ONLY_CLOCK_REALTIME is defined])])
 
 AC_ARG_ENABLE([safe-limits],
   AS_HELP_STRING([--enable-safe-limits], [Restrict timing parameters (-i, -p) within "safe" limits]))
index e02dab51021e7cea8dfe7fd3cf3286776b3256c9..27711c8f765b7766c9f5cd2b0910dd31eee6daa5 100644 (file)
@@ -116,15 +116,16 @@ extern int h_errno;
 
 /*** Constants ***/
 
-#if HAVE_SO_TIMESTAMPNS
-#define CLOCKID CLOCK_REALTIME
-#endif
-
 /* CLOCK_MONTONIC starts under macOS, OpenBSD and FreeBSD with undefined positive point and can not be use
  * see github PR #217
+ * The configure script detect the predefined operating systems an set CLOCK_REALTIME using over ONLY_CLOCK_REALTIME variable
  */
+#if HAVE_SO_TIMESTAMPNS || ONLY_CLOCK_REALTIME
+#define CLOCKID CLOCK_REALTIME
+#endif
+
 #if !defined(CLOCKID)
-#if defined(CLOCK_MONOTONIC) && !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
+#if defined(CLOCK_MONOTONIC)
 #define CLOCKID CLOCK_MONOTONIC
 #else
 #define CLOCKID CLOCK_REALTIME