]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1174] Fixed the same duration type bug
authorFrancis Dupont <fdupont@isc.org>
Wed, 15 Jul 2020 19:46:39 +0000 (21:46 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 15 Jul 2020 19:46:39 +0000 (21:46 +0200)
configure.ac
src/lib/util/chrono_time_utils.cc

index c4ed915a8d24378176f5f8c88c7f9b22623a4c63..d162879d62cabc43f1c00c7b1cab205a6e346efd 100755 (executable)
@@ -172,6 +172,21 @@ AC_COMPILE_IFELSE(
     [Define to 1 if std::is_base_of is available])],
     [AC_MSG_RESULT(no)])
 
+# Check if system and steady clocks use the same duration type.
+AC_MSG_CHECKING([for different std::chrono::duration types])
+AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM(
+        [#include <chrono>
+        #include <type_traits>]
+       [static_assert(!std::is_same<
+                           std::chrono::system_clock::duration,
+                          std::chrono::steady_clock::duration
+                                   >::value, "");])],
+    [AC_MSG_RESULT(yes)],
+    [AC_MSG_RESULT(no)
+    AC_DEFINE([CHRONO_SAME_DURATION], [1],
+    [Define to 1 if system and steady clocks use the same duration type])])
+
 dnl Determine if we are using GNU sed
 GNU_SED=no
 $SED --version 2> /dev/null | grep GNU > /dev/null 2>&1
index 1bc3a13a7c449cd48fd84b990afe4905469ea88d..6c76112fd441fb0661c47e2a72f103dbdb52add7 100644 (file)
@@ -92,9 +92,11 @@ template std::string
 durationToText<system_clock::duration>(system_clock::duration dur,
                                        size_t fsecs_precision);
 
+#if !CHRONO_SAME_DURATION
 template std::string
 durationToText<steady_clock::duration>(steady_clock::duration dur,
                                        size_t fsecs_precision);
+#endif
 
 } // end of isc::util namespace
 } // end of isc namespace