aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/ntp/scripts/calc_tickadj
diff options
context:
space:
mode:
authorOllivier Robert <roberto@FreeBSD.org>1999-12-09 13:01:21 +0000
committerOllivier Robert <roberto@FreeBSD.org>1999-12-09 13:01:21 +0000
commitc0b746e5e8d9479f05b3749cbf1f73b8928719bd (patch)
treefc0cfa1aab0ff6b228f511b410733ef4f35d1ead /contrib/ntp/scripts/calc_tickadj
downloadsrc-c0b746e5e8d9479f05b3749cbf1f73b8928719bd.tar.gz
src-c0b746e5e8d9479f05b3749cbf1f73b8928719bd.zip
Virgin import of ntpd 4.0.98fvendor/ntp/4.0.98f
Notes
Notes: svn path=/vendor/ntp/dist/; revision=54359 svn path=/vendor/ntp/4.0.98f/; revision=54361; tag=vendor/ntp/4.0.98f
Diffstat (limited to 'contrib/ntp/scripts/calc_tickadj')
-rw-r--r--contrib/ntp/scripts/calc_tickadj38
1 files changed, 38 insertions, 0 deletions
diff --git a/contrib/ntp/scripts/calc_tickadj b/contrib/ntp/scripts/calc_tickadj
new file mode 100644
index 000000000000..f7a9f9f1d799
--- /dev/null
+++ b/contrib/ntp/scripts/calc_tickadj
@@ -0,0 +1,38 @@
+#! /usr/local/bin/perl
+#
+# drift of 104.8576 -> +1 tick. Base of 10000 ticks.
+#
+# 970306 HMS Deal with nanoseconds. Fix sign of adjustments.
+
+$df="/etc/ntp.drift";
+# Assumes a 100Hz box with "tick" of 10000
+# Someday, we might call "tickadj" for better values...
+$base=10000; # tick: 1,000,000 / HZ
+$cvt=104.8576; # 2 ** 20 / $base
+$v1=0.;
+$v2="";
+
+if (open(DF, $df))
+ {
+ if ($_=<DF>)
+ {
+ ($v1, $v2) = split;
+ }
+
+ while ($v1 < 0)
+ {
+ $v1 += $cvt;
+ $base--;
+ }
+
+ while ($v1 > $cvt)
+ {
+ $v1 -= $cvt;
+ $base++;
+ }
+ }
+
+printf("%.3f (drift)\n", $v1);
+
+printf("%d usec; %d nsec\n", $base, ($base + ($v1/$cvt)) * 1000);
+