mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 02:05:06 -05:00
local: round log value of clock precision
This is similar to what the reference NTP implementation does. With 1us clock resolution that gives -20 instead of -19.
This commit is contained in:
6
local.c
6
local.c
@@ -126,11 +126,15 @@ calculate_sys_precision(void)
|
|||||||
assert(best_dusec > 0);
|
assert(best_dusec > 0);
|
||||||
|
|
||||||
precision_quantum = best_dusec * 1.0e-6;
|
precision_quantum = best_dusec * 1.0e-6;
|
||||||
|
|
||||||
|
/* Get rounded log2 value of the measured precision */
|
||||||
precision_log = 0;
|
precision_log = 0;
|
||||||
while (best_dusec < 500000) {
|
while (best_dusec < 707107) {
|
||||||
precision_log--;
|
precision_log--;
|
||||||
best_dusec *= 2;
|
best_dusec *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG_LOG(LOGF_Local, "Clock precision %.9f (%d)", precision_quantum, precision_log);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|||||||
Reference in New Issue
Block a user