/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

  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. $df="/etc/ntp.drift";
  7. # Assumes a 100Hz box with "tick" of 10000
  8. # Someday, we might call "tickadj" for better values...
  9. $base=10000; # tick: 1,000,000 / HZ
  10. $cvt=104.8576; # 2 ** 20 / $base
  11. $v1=0.;
  12. $v2="";
  13. if (open(DF, $df))
  14. {
  15. if ($_=<DF>)
  16. {
  17. ($v1, $v2) = split;
  18. }
  19. while ($v1 < 0)
  20. {
  21. $v1 += $cvt;
  22. $base--;
  23. }
  24. while ($v1 > $cvt)
  25. {
  26. $v1 -= $cvt;
  27. $base++;
  28. }
  29. }
  30. printf("%.3f (drift)\n", $v1);
  31. printf("%d usec; %d nsec\n", $base, ($base + ($v1/$cvt)) * 1000);