)
])
+AC_DEFUN([BIRD_CHECK_CLOCK],
+[
+ AC_CACHE_CHECK(
+ [for $1],
+ [bird_cv_clock_$1],
+ [
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_PROGRAM(
+ [
+ #include <time.h>
+ ],
+ [
+ struct timespec tv;
+ clock_gettime($1, &tv);
+ ]
+ )
+ ],
+ [bird_cv_clock_$1=yes],
+ [bird_cv_clock_$1=no]
+ )
+ ]
+ )
+])
+
AC_DEFUN([BIRD_CHECK_ANDROID_GLOB],
[
AC_CACHE_CHECK(
fi
fi
+BIRD_CHECK_CLOCK(CLOCK_MONOTONIC)
+if test "$bird_cv_clock_CLOCK_MONOTONIC" != yes ; then
+ AC_MSG_ERROR([Monotonic clock not supported])
+fi
+
+BIRD_CHECK_CLOCK(CLOCK_MONOTONIC_COARSE)
+if test "$bird_cv_clock_CLOCK_MONOTONIC_COARSE" != yes ; then
+ AC_DEFINE([HAVE_CLOCK_MONOTONIC_COARSE], [0], [Define to 1 if coarse clock is available])
+else
+ AC_DEFINE([HAVE_CLOCK_MONOTONIC_COARSE], [1], [Define to 1 if coarse clock is available])
+fi
+
# temporarily removed "mrt" from all_protocols to speed up 3.0-alpha1 release
all_protocols="aggregator bfd babel bgp l3vpn ospf pipe radv rip rpki static"
all_protocols=`echo $all_protocols | sed 's/ /,/g'`
* BIRD for such a long time, please implement some means of overflow prevention.
*/
+#if ! HAVE_CLOCK_MONOTONIC_COARSE
+#define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
+#endif
+
static struct timespec ns_begin;
static void ns_init(void)
{
- if (clock_gettime(CLOCK_MONOTONIC, &ns_begin))
+ if (clock_gettime(CLOCK_MONOTONIC_COARSE, &ns_begin))
bug("clock_gettime: %m");
}
u64 ns_now(void)
{
struct timespec ts;
- if (clock_gettime(CLOCK_MONOTONIC, &ts))
+ if (clock_gettime(CLOCK_MONOTONIC_COARSE, &ts))
bug("clock_gettime: %m");
return (u64) (ts.tv_sec - ns_begin.tv_sec) * NSEC_IN_SEC + ts.tv_nsec - ns_begin.tv_nsec;