From c0aaeafe4ccb6529d47f3fc57ef3df688335c696 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Fri, 29 Jul 2011 16:31:52 +0200 Subject: [PATCH 2/2] In mdate(), use the FreeBSD's CLOCK_MONOTONIC_FAST if available. It's faster than CLOCK_MONOTONIC but seems to be accurate enough for mdate(). It returns a cached value that is updated at least each kernel tick. --- src/misc/mtime.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/src/misc/mtime.c b/src/misc/mtime.c index f8d69dc..449282d 100644 --- a/src/misc/mtime.c +++ b/src/misc/mtime.c @@ -200,6 +200,15 @@ mtime_t mdate( void ) #if defined (HAVE_CLOCK_GETTIME) struct timespec ts; +#if defined CLOCK_MONOTONIC_FAST + /* + * The FreeBSD extension CLOCK_MONOTONIC_FAST is + * faster than CLOCK_MONOTONIC and seems to be + * accurate enough for mdate(). It's updated at + * least each kernel tick. + */ + if( clock_gettime( CLOCK_MONOTONIC_FAST, &ts ) == EINVAL ) +#endif /* Try to use POSIX monotonic clock if available */ if( clock_gettime( CLOCK_MONOTONIC, &ts ) == EINVAL ) /* Run-time fallback to real-time clock (always available) */ -- 1.7.6