/contrib/ntp/scripts/calc_tickadj.in
https://bitbucket.org/freebsd/freebsd-head/ · Autoconf · 38 lines · 24 code · 7 blank · 7 comment · 4 complexity · ed75c516d316c5124da8da0aee0f90e8 MD5 · raw file
- #! @PATH_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);