mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-08 12:18:42 +00:00
Time accounting must be done by coarse timers
on some ARM, the precise timers are too slow to be actually useful
This commit is contained in:
parent
4d01ca3e8f
commit
5c8179d63a
25
aclocal.m4
vendored
25
aclocal.m4
vendored
@ -120,6 +120,31 @@ AC_DEFUN([BIRD_CHECK_MPLS_KERNEL],
|
|||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
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_DEFUN([BIRD_CHECK_ANDROID_GLOB],
|
||||||
[
|
[
|
||||||
AC_CACHE_CHECK(
|
AC_CACHE_CHECK(
|
||||||
|
12
configure.ac
12
configure.ac
@ -308,6 +308,18 @@ if test "$enable_mpls_kernel" != no ; then
|
|||||||
fi
|
fi
|
||||||
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
|
# 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="aggregator bfd babel bgp l3vpn ospf pipe radv rip rpki static"
|
||||||
all_protocols=`echo $all_protocols | sed 's/ /,/g'`
|
all_protocols=`echo $all_protocols | sed 's/ /,/g'`
|
||||||
|
@ -42,11 +42,15 @@ static struct birdloop *birdloop_new_no_pickup(pool *pp, uint order, const char
|
|||||||
* BIRD for such a long time, please implement some means of overflow prevention.
|
* 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 struct timespec ns_begin;
|
||||||
|
|
||||||
static void ns_init(void)
|
static void ns_init(void)
|
||||||
{
|
{
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ns_begin))
|
if (clock_gettime(CLOCK_MONOTONIC_COARSE, &ns_begin))
|
||||||
bug("clock_gettime: %m");
|
bug("clock_gettime: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +59,7 @@ static void ns_init(void)
|
|||||||
u64 ns_now(void)
|
u64 ns_now(void)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ts))
|
if (clock_gettime(CLOCK_MONOTONIC_COARSE, &ts))
|
||||||
bug("clock_gettime: %m");
|
bug("clock_gettime: %m");
|
||||||
|
|
||||||
return (u64) (ts.tv_sec - ns_begin.tv_sec) * NSEC_IN_SEC + ts.tv_nsec - ns_begin.tv_nsec;
|
return (u64) (ts.tv_sec - ns_begin.tv_sec) * NSEC_IN_SEC + ts.tv_nsec - ns_begin.tv_nsec;
|
||||||
|
Loading…
Reference in New Issue
Block a user