]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
local: round log value of clock precision
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 4 Jun 2014 08:48:03 +0000 (10:48 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 4 Jun 2014 10:12:04 +0000 (12:12 +0200)
This is similar to what the reference NTP implementation does. With 1us
clock resolution that gives -20 instead of -19.

local.c

diff --git a/local.c b/local.c
index 513779ebe9da831fd667591cddb5c39a083292e5..158aa0cb7ca9900141ed51babe2d1ae4f7809ab6 100644 (file)
--- a/local.c
+++ b/local.c
@@ -126,11 +126,15 @@ calculate_sys_precision(void)
   assert(best_dusec > 0);
 
   precision_quantum = best_dusec * 1.0e-6;
+
+  /* Get rounded log2 value of the measured precision */
   precision_log = 0;
-  while (best_dusec < 500000) {
+  while (best_dusec < 707107) {
     precision_log--;
     best_dusec *= 2;
   }
+
+  DEBUG_LOG(LOGF_Local, "Clock precision %.9f (%d)", precision_quantum, precision_log);
 }
 
 /* ================================================== */