aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2002-02-22 12:59:20 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2002-02-22 12:59:20 +0000
commit4e2befc031b0a461523f783c10a5b088fef37830 (patch)
tree9344581ffdf56a17985a8b083ed65f0c3bfb273d /sys
parent6e47a4f6464285667341ff6d580048517df63145 (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_tc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 71b9e5adf5bd..a6b300eb808a 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -207,7 +207,13 @@ tco_setscales(struct timecounter *tc)
/* Sacrifice the lower bit to the deity for code clarity */
scale = 1ULL << 63;
- scale += (tc->tc_adjustment * 4295LL) / 1000LL;
+ /*
+ * We get nanoseconds with 32 bit binary fraction and want
+ * 64 bit binary fraction: x = a * 2^32 / 10^9 = a * 4.294967296
+ * The range is +/- 500PPM so we can multiply by about 8500
+ * without overflowing. 4398/1024 = is very close to ideal.
+ */
+ scale += (tc->tc_adjustment * 4398) >> 10;
scale /= tc->tc_tweak->tc_frequency;
tc->tc_scale = scale * 2;
}