Annotation of embedaddon/ntp/scripts/calc_tickadj.in, revision 1.1.1.1
1.1 misho 1: #! @PATH_PERL@
2: #
3: # drift of 104.8576 -> +1 tick. Base of 10000 ticks.
4: #
5: # 970306 HMS Deal with nanoseconds. Fix sign of adjustments.
6:
7: $df="/etc/ntp.drift";
8: # Assumes a 100Hz box with "tick" of 10000
9: # Someday, we might call "tickadj" for better values...
10: $base=10000; # tick: 1,000,000 / HZ
11: $cvt=104.8576; # 2 ** 20 / $base
12: $v1=0.;
13: $v2="";
14:
15: if (open(DF, $df))
16: {
17: if ($_=<DF>)
18: {
19: ($v1, $v2) = split;
20: }
21:
22: while ($v1 < 0)
23: {
24: $v1 += $cvt;
25: $base--;
26: }
27:
28: while ($v1 > $cvt)
29: {
30: $v1 -= $cvt;
31: $base++;
32: }
33: }
34:
35: printf("%.3f (drift)\n", $v1);
36:
37: printf("%d usec; %d nsec\n", $base, ($base + ($v1/$cvt)) * 1000);
38:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>