]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
.del-ntp_loopfilter.c.1~3aed0663:
authorHarlan Stenn <stenn@ntp.org>
Fri, 3 Sep 1999 03:22:21 +0000 (03:22 -0000)
committerHarlan Stenn <stenn@ntp.org>
Fri, 3 Sep 1999 03:22:21 +0000 (03:22 -0000)
  Removed spurious file
Many files:
  * ntptrace/ntptrace.c:
  * ntpdate/ntptimeset.c:
  * ntpdate/ntptime_config.c:
  * ntpdate/ntpdate.c:
  * util/ntptime.c:
  * parseutil/dcfd.c:
  * libparse/parsestreams.c:
  * libparse/parse_conf.c:
  * libparse/parse.c:
  * libparse/clk_varitext.c:
  * libparse/clk_trimtsip.c:
  * libparse/clk_trimtaip.c:
  * libparse/clk_schmid.c:
  * libparse/clk_rcc8000.c:
  * libparse/clk_rawdcf.c:
  * libparse/clk_meinberg.c:
  * libparse/clk_hopf6021.c:
  * libparse/clk_dcf7000.c:
  * libparse/clk_computime.c:
  * libntp/msyslog.c:
  * libntp/iosignal.c:
  * libntp/syssignal.c:
  * adjtimed/adjtimed.c:
  * ntpd/refclock_shm.c:
  * ntpd/refclock_parse.c:
  * ntpd/refclock_palisade.c:
  * ntpd/refclock_mx4200.c:
  * ntpd/refclock_jupiter.c:
  * ntpd/refclock_datum.c:
  * ntpd/ntpd.c:
  * ntpd/ntp_util.c:
  * ntpd/ntp_timer.c:
  * ntpd/ntp_request.c:
  * ntpd/ntp_refclock.c:
  * ntpd/ntp_monitor.c:
  * ntpd/ntp_loopfilter.c:
  * ntpd/ntp_io.c:
  * ntpd/ntp_intres.c:
  * ntpd/ntp_filegen.c:
  * include/l_stdlib.h:
  <errno.h> and errno declaration cleanup.
  * ntpd/map_vme.c: cleanup some spacing.

bk: 37cf3eedDlKsLJYHxLLWjuYujad-eg

43 files changed:
ChangeLog
adjtimed/adjtimed.c
include/l_stdlib.h
libntp/iosignal.c
libntp/msyslog.c
libntp/syssignal.c
libparse/clk_computime.c
libparse/clk_dcf7000.c
libparse/clk_hopf6021.c
libparse/clk_meinberg.c
libparse/clk_rawdcf.c
libparse/clk_rcc8000.c
libparse/clk_schmid.c
libparse/clk_trimtaip.c
libparse/clk_trimtsip.c
libparse/clk_varitext.c
libparse/parse.c
libparse/parse_conf.c
libparse/parsestreams.c
ntpd/map_vme.c
ntpd/ntp_filegen.c
ntpd/ntp_intres.c
ntpd/ntp_io.c
ntpd/ntp_loopfilter.c
ntpd/ntp_loopfilter.c.1 [deleted file]
ntpd/ntp_monitor.c
ntpd/ntp_refclock.c
ntpd/ntp_request.c
ntpd/ntp_timer.c
ntpd/ntp_util.c
ntpd/ntpd.c
ntpd/refclock_datum.c
ntpd/refclock_jupiter.c
ntpd/refclock_mx4200.c
ntpd/refclock_palisade.c
ntpd/refclock_parse.c
ntpd/refclock_shm.c
ntpdate/ntpdate.c
ntpdate/ntptime_config.c
ntpdate/ntptimeset.c
ntptrace/ntptrace.c
parseutil/dcfd.c
util/ntptime.c

index 25548845cd3d2fe9d6b8a0653960c85bb2583f36..9117fdb7e50644becf5827ea71ea15aee1a2726e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,49 @@
+1999-09-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntptrace/ntptrace.c:
+       * ntpdate/ntptimeset.c:
+       * ntpdate/ntptime_config.c:
+       * ntpdate/ntpdate.c:
+       * util/ntptime.c:
+       * parseutil/dcfd.c:
+       * libparse/parsestreams.c:
+       * libparse/parse_conf.c:
+       * libparse/parse.c:
+       * libparse/clk_varitext.c:
+       * libparse/clk_trimtsip.c:
+       * libparse/clk_trimtaip.c:
+       * libparse/clk_schmid.c:
+       * libparse/clk_rcc8000.c:
+       * libparse/clk_rawdcf.c:
+       * libparse/clk_meinberg.c:
+       * libparse/clk_hopf6021.c:
+       * libparse/clk_dcf7000.c:
+       * libparse/clk_computime.c:
+       * libntp/msyslog.c:
+       * libntp/iosignal.c:
+       * libntp/syssignal.c:
+       * adjtimed/adjtimed.c:
+       * ntpd/refclock_shm.c:
+       * ntpd/refclock_parse.c:
+       * ntpd/refclock_palisade.c:
+       * ntpd/refclock_mx4200.c:
+       * ntpd/refclock_jupiter.c:
+       * ntpd/refclock_datum.c:
+       * ntpd/ntpd.c:
+       * ntpd/ntp_util.c:
+       * ntpd/ntp_timer.c:
+       * ntpd/ntp_request.c:
+       * ntpd/ntp_refclock.c:
+       * ntpd/ntp_monitor.c:
+       * ntpd/ntp_loopfilter.c:
+       * ntpd/ntp_io.c:
+       * ntpd/ntp_intres.c:
+       * ntpd/ntp_filegen.c:
+       * include/l_stdlib.h:
+       <errno.h> and errno declaration cleanup.
+
+       * ntpd/map_vme.c: cleanup some spacing.
+
 1999-09-01  Harlan Stenn  <stenn@whimsy.udel.edu>
 
        * configure.in: 4.0.97e
index 6280f92ac2a480c3e2e5448582e6d39cfae477be..f38e66dd0f758dcbb5bb3afdbe803525d63a2c52 100644 (file)
@@ -36,9 +36,11 @@ static char RCSid[] = "adjtimed.c,v 3.1 1993/07/06 01:04:45 jbj Exp";
 #include <nlist.h>
 #include <fcntl.h>
 #include <stdio.h>
-#include <errno.h>
 #include <unistd.h>
+
 #include "ntp_syslog.h"
+#include "ntp_stdlib.h"
+
 #include "adjtime.h"
 
 double atof (const char *);
index 7ec68073e602cd8ab8623b484c8aea3ad84e8151..0be5b8f26528adb3075daea7529ad60596e2273e 100644 (file)
 # include <termios.h>
 #endif
 
+#ifdef HAVE_ERRNO_H
+# include <errno.h>
+#endif
+
 #include "ntp_types.h"
 #include "ntp_proto.h"
 
index a9a742a4b2b4a8f423bcd2858d62e9aad3b8be40..8b7315b9293bc66a11e491abba06d055290b6867 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <stdio.h>
 #include <signal.h>
-#include <errno.h>
 #include <sys/types.h>
 #ifdef HAVE_SYS_PARAM_H
 # include <sys/param.h>
index ef0bf433a975bfe05f546cce4d7d054d89b6343a..d5a25fc33095dc6ef7152b2f5f5b736ef70be40f 100644 (file)
@@ -4,8 +4,9 @@
  *
  * Converted to use varargs, much better ... jks
  */
+
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #ifdef HAVE_SYS_TYPES_H
@@ -16,7 +17,6 @@
 #endif
 
 #include <stdio.h>
-#include <errno.h>
 
 #include "ntp_types.h"
 #include "ntp_string.h"
index 1f0d335184884b09aea7de4e88d64253358dca1e..d457410c12a9613c1c1f776e6d965c0104b9958a 100644 (file)
@@ -1,3 +1,7 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <stdio.h>
 #include <sys/types.h>
 #include <signal.h>
@@ -6,9 +10,6 @@
 #include "ntp_stdlib.h"
 
 #ifdef HAVE_SIGACTION
-#include <errno.h>
-
-extern int errno;
 
 void
 signal_no_reset(
index 3622d64b98690cbd9431c8198dd3a233e8ae4ec6..8e050c00fcadfc981f07656eb2911b663daa03a6 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_COMPUTIME)
  */
 
 
-#include "sys/types.h"
-#include "sys/time.h"
-#include "sys/errno.h"
+#include <sys/types.h>
+#include <sys/time.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
-
+#include "ntp_stdlib.h"
 
 #include "parse.h"
 
 #ifndef PARSESTREAM
-#include "ntp_stdlib.h"
 #include <stdio.h>
 #else
 #include "sys/parsestreams.h"
index a257f4d780d69bc1b36f33e0e168f78a26620d6b..845b46716d08753655d485731aa46fe318bb253d 100644 (file)
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_DCF7000)
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <sys/errno.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
index 75794140afdb90ec5530a491b01e713920f8c97f..06efc6ff6dc2aa6462115a9f400e2a5926e96bbd 100644 (file)
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_HOPF6021)
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <sys/errno.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
index 599a1ef1e28580d2c5ab49b70836d40ef346c97b..fdffa1bf33c6e4e88ef34bfe1defd19b215f1a75 100644 (file)
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_MEINBERG)
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <sys/errno.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
index d84d0b2490bb95a8bad4c11ac39e2c00b9453630..ac854c57b2238f42711df32fd306cd4ae80a990e 100644 (file)
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_RAWDCF)
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <sys/errno.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
 
 #include "parse.h"
 #ifdef PARSESTREAM
-#include <sys/parsestreams.h>
+# include <sys/parsestreams.h>
 #endif
 
 #ifndef PARSEKERNEL
-#include "ntp_stdlib.h"
+# include "ntp_stdlib.h"
 #endif
 
 /*
index 935a1e15eeae2065c8ac61d384ab0fd3a77b241d..09405c73d20e8e0ffe8512b8301496af5bf53f85 100644 (file)
  */
 
 #if HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_RCC8000)
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <sys/errno.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
index b4c3caa2dab13df84ebfb282d90a812bd84fb493..049b4e49c02d211c0b14390e22773175ad523bd6 100644 (file)
  */
 
 #if HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_SCHMID)
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <sys/errno.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
index 6ca77ec765289c66814f037ca7153d7d5c185dfb..2fd1eab7469408f74f96151cea28e05f7ea4dc9a 100644 (file)
@@ -7,14 +7,13 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_TRIMTAIP)
-
 #include <sys/types.h>
 #include <sys/time.h>
-#include <sys/errno.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
index 9c9baa6a19aed20893989fa423d5f68eb212ff2b..52a753649ea66281232c361a275058dbcc7bd3d8 100644 (file)
@@ -7,14 +7,13 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_TRIMTSIP)
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <sys/errno.h>
 
 #include "ntp_syslog.h"
 #include "ntp_types.h"
@@ -22,6 +21,7 @@
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
 #include "ntp_machine.h"
+#include "ntp_stdlib.h"
 
 #include "parse.h"
 
 #include "sys/parsestreams.h"
 # endif
 
-#include "ntp_stdlib.h"
-
-#include "ntp_stdlib.h"
-
 #include "ascii.h"
 #include "binio.h"
 #include "ieee754io.h"
index 34113a90719f7d82346fc0a8f037610172f2a8a1..9236bb4b8c9ac884350673693621a56167ca1ea4 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_VARITEXT)
@@ -19,9 +19,9 @@
  * 
  */
 
-#include "sys/types.h"
-#include "sys/time.h"
-#include "sys/errno.h"
+#include <sys/types.h>
+#include <sys/time.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
index cb59a397d7db751a8deaf234b6a3ef7fb65e9dd1..3d8485e142547c33c69403afecedc0e3ce76dd8a 100644 (file)
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#if 0 
-#ifdef NeXT
-/*
- * This is lame, but gets us a symbol for the libparse library so the NeXTstep
- * ranlib doesn't stop the compile.
- */
-void
-token_libparse_symbol(void)
-{
-}
-#endif
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE)
@@ -45,16 +32,15 @@ static char rcsid[] = "parse.c,v 4.13 1999/02/28 11:50:20 kardel RELEASE_1999022
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <errno.h>
 
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
-
+#include "ntp_stdlib.h"
 #include "ntp_machine.h"
+#include "ntp.h"               /* (get Y2KFixes definitions)   Y2KFixes */
 
 #include "parse.h"
-#include "ntp.h"               /* (get Y2KFixes definitions)   Y2KFixes */
 
 #ifndef PARSESTREAM
 #include <stdio.h>
@@ -62,10 +48,6 @@ static char rcsid[] = "parse.c,v 4.13 1999/02/28 11:50:20 kardel RELEASE_1999022
 #include "sys/parsestreams.h"
 #endif
 
-#include "ntp_stdlib.h"
-
-#include "ntp_stdlib.h"
-
 extern clockformat_t *clockformats[];
 extern unsigned short nformats;
 
index 934d96772b9b35406cda62ce606f1c96727487bb..3333cd97d6e15c1d2e505364c11fe511689a147b 100644 (file)
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_PARSE)
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <errno.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_calendar.h"
index 71afa262466b6218192a58f5081f63d1028ab165..1578229e19a81504ea3397fbb45e334056be8f3f 100644 (file)
@@ -19,7 +19,7 @@
 #define VDDRV                  /* SHOULD */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+# include "config.h"
 #endif
 
 #ifndef lint
@@ -35,7 +35,6 @@ static char rcsid[] = "parsestreams.c,v 4.6 1998/12/20 23:45:31 kardel RELEASE_1
 #include <sys/buf.h>
 #include <sys/param.h>
 #include <sys/sysmacros.h>
-#include <sys/errno.h>
 #include <sys/time.h>
 #include <sundev/mbvar.h>
 #include <sun/autoconf.h>
@@ -47,7 +46,6 @@ static char rcsid[] = "parsestreams.c,v 4.6 1998/12/20 23:45:31 kardel RELEASE_1
 #include <sys/termio.h>
 #include <sys/ttold.h>
 #include <sys/user.h>
-#include <sys/errno.h>
 #include <sys/tty.h>
 
 #ifdef VDDRV
index 0d02e6b8100f6707267098e52386c6d70bcfd0c3..3c161cc91450e9f16223f11136be69983043650e 100644 (file)
@@ -22,8 +22,8 @@
 #include <sys/types.h> 
 #include <sys/stat.h> 
 #include <sys/sysmacros.h> 
-#include <sys/rtprio.h> /* for rtprio */
-#include <sys/lock.h> /* for plock */
+#include <sys/rtprio.h>                /* for rtprio */
+#include <sys/lock.h>          /* for plock */
 #include "/etc/conf/machine/vme2.h"
 #include "/etc/conf/h/io.h"
 #include "gps.h"
@@ -119,13 +119,13 @@ init_vme(boid)
 
 /* offsets from base address: */
 
-       greg[0] =  (unsigned short *)gps_base + GFRZ1;
+       greg[0] = (unsigned short *)gps_base + GFRZ1;
        greg[1] = (unsigned short *)gps_base + GUFRZ1;
        greg[2] = (unsigned short *)gps_base + GREG1A;
-       greg[3] = (unsigned short  *)gps_base + GREG1B;
-       greg[4] = (unsigned short  *)gps_base + GREG1C;
-       greg[5] = (unsigned short  *)gps_base + GREG1D;
-       greg[6] = (unsigned short  *)gps_base + GREG1E;
+       greg[3] = (unsigned short *)gps_base + GREG1B;
+       greg[4] = (unsigned short *)gps_base + GREG1C;
+       greg[5] = (unsigned short *)gps_base + GREG1D;
+       greg[6] = (unsigned short *)gps_base + GREG1E;
 
        return (0); 
 }
index 445c3d049563906ee1a5d4591b2f6095cbccac3d..bcf3f9c19cd186b12c3f22c86974d653cc7fe793 100644 (file)
@@ -19,7 +19,6 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <errno.h>
 
 #include "ntpd.h"
 #include "ntp_io.h"
index 4bc1c93010176b1ff478ebd9877fc4b0be742016..96e111c658edde14d61ae23b941587a710794cdf 100644 (file)
@@ -26,7 +26,6 @@
 #include <sys/time.h>
 #include <netdb.h>
 #include <signal.h>
-#include <errno.h>
 
 #include "ntpd.h"
 #include "ntp_select.h"
index 96f265d90dc4ad56b09b00c446784536c1609905..f788d8cbe8c834a403f7f0deae93e1a9de2af0b1 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <stdio.h>
 #include <signal.h>
-#include <errno.h>
 #include <sys/types.h>
 #ifdef HAVE_SYS_PARAM_H
 # include <sys/param.h>
index a501931e6f4d2fa9ae413d0b1d824465b8757f5b..c3fe93f43f69c801b9f3b10efcab98da981719d7 100644 (file)
@@ -12,8 +12,8 @@
 
 
 #include <signal.h>
-#include <errno.h>
 #include <setjmp.h>
+
 #include "ntpd.h"
 #include "ntp_io.h"
 #include "ntp_unixtime.h"
diff --git a/ntpd/ntp_loopfilter.c.1 b/ntpd/ntp_loopfilter.c.1
deleted file mode 100644 (file)
index 209c5f3..0000000
+++ /dev/null
@@ -1,873 +0,0 @@
-/*
- * ntp_loopfilter.c - implements the NTP loop filter algorithm
- *
- */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/time.h>
-
-
-#include <signal.h>
-#include <errno.h>
-#include <setjmp.h>
-#include "ntpd.h"
-#include "ntp_io.h"
-#include "ntp_unixtime.h"
-#include "ntp_stdlib.h"
-
-#if defined(VMS) && defined(VMS_LOCALUNIT)     /*wjm*/
-#include "ntp_refclock.h"
-#endif /* VMS */
-
-#ifdef KERNEL_PLL
-#ifdef HAVE_SYS_TIMEX_H
-#include <sys/timex.h>
-#endif
-#ifdef NTP_SYSCALLS_STD
-#define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t))
-#else /* NOT NTP_SYSCALLS_STD */
-#ifdef HAVE___ADJTIMEX
-#define ntp_adjtime(t) __adjtimex((t))
-#endif
-#endif /* NOT NTP_SYSCALLS_STD */
-#endif /* KERNEL_PLL */
-
-/*
- * This is an implementation of the clock discipline algorithm described
- * in UDel TR 97-4-3, as amended. It operates as an adaptive parameter,
- * hybrid phase/frequency-lock oscillator. A number of sanity checks are
- * included to protect against timewarps, timespikes and general mayhem.
- * All units are in s and s/s, unless noted otherwise.
- */
-#define CLOCK_MAX      .128    /* default max offset (s) */
-#define CLOCK_PANIC    1000.   /* default panic offset (s) */
-#define CLOCK_MAXSTAB  2e-6    /* max frequency stability */
-#define CLOCK_MAXERR   1e-2    /* max phase jitter (s) */
-#define SHIFT_PLL      4       /* PLL loop gain (shift) */
-#define CLOCK_AVG      4.      /* FLL loop gain */
-#define CLOCK_MINSEC   256.    /* min FLL update interval (s) */
-#define CLOCK_MINSTEP  900.    /* step-change timeout (s) */
-#define CLOCK_DAY      86400.  /* one day of seconds */
-#define CLOCK_LIMIT    30      /* poll-adjust threshold */
-#define CLOCK_PGATE    4.      /* poll-adjust gate */
-#define CLOCK_ALLAN    1024.   /* min Allan intercept (s) */
-#define CLOCK_ADF      1e11    /* Allan deviation factor */
-
-/*
- * Clock discipline state machine. This is used to control the
- * synchronization behavior during initialization and following a
- * timewarp. 
- */
-#define S_NSET 0               /* clock never set */
-#define S_FSET 1               /* frequency set from the drift file */
-#define S_TSET 2               /* time set */
-#define S_FREQ 3               /* frequency mode */
-#define S_SYNC 4               /* clock synchronized */
-#define S_SPIK 5               /* spike detected */
-
-/*
- * Kernel PLL/PPS state machine. This is used with the kernel PLL
- * modifications described in the README.kernel file.
- *
- * If kernel support for the ntp_adjtime() system call is available, the
- * ntp_control flag is set. The ntp_enable and kern_enable flags can be
- * set at configuration time or run time using ntpdc. If ntp_enable is
- * false, the discipline loop is unlocked and no correctios of any kind
- * are made. If both ntp_control and kern_enable are set, the kernel
- * support is used as described above; if false, the kernel is bypassed
- * entirely and the daemon PLL used instead.
- *
- * Each update to a prefer peer sets pps_update if it survives the
- * intersection algorithm and its time is within range. The PPS time
- * discipline is enabled (STA_PPSTIME bit set in the status word) when
- * pps_update is true and the PPS frequency discipline is enabled. If
- * the PPS time discipline is enabled and the kernel reports a PPS
- * signal is present, the pps_control variable is set to the current
- * time. If the current time is later than pps_control by PPS_MAXAGE
- * (120 s), this variable is set to zero.
- *
- * If an external clock is present, the clock driver sets STA_CLK in the
- * status word. When the local clock driver sees this bit, it updates
- * via this routine, which then calls ntp_adjtime() with the STA_PLL bit
- * set to zero, in which case the system clock is not adjusted. This is
- * also a signal for the external clock driver to discipline the system
- * clock.
- */
-#define PPS_MAXAGE 120         /* kernel pps signal timeout (s) */
-
-/*
- * Program variables
- */
-double clock_offset;           /* clock offset adjustment */
-double drift_comp;             /* clock frequency (ppm) */
-double clock_stability;        /* clock stability (ppm) */
-double clock_max = CLOCK_MAX;  /* max offset allowed before step */
-double clock_panic = CLOCK_PANIC; /* max offset allowed before panic */
-u_long pps_control;            /* last pps sample time */
-#ifdef KERNEL_PLL
-static int pll_status;         /* status bits for kernel pll */
-#endif /* KERNEL_PLL */
-static void rstclock P((int)); /* state transition function */
-
-/*
- * Clock state machine control flags
- */
-int    ntp_enable;             /* clock discipline enabled */
-int    pll_control;            /* kernel support available */
-int    kern_enable;            /* kernel support enabled */
-#ifdef STA_NANO
-int    pll_nano;               /* nanosecond kernel */
-#endif /* STA_NANO */
-int    ext_enable;             /* external clock enabled */
-int    pps_update;             /* pps update valid */
-int    allow_set_backward = TRUE; /* step corrections allowed */
-int    correct_any = FALSE;    /* corrections > 1000 s allowed */
-
-/*
- * Clock state machine variables
- */
-int    state;                  /* clock discipline state */
-u_char sys_poll;               /* log2 of system poll interval */
-int    tc_counter;             /* poll-adjust counter */
-u_long last_time;              /* time of last clock update (s) */
-double last_offset;            /* last clock offset (s) */
-double allan_xpt;              /* Allan intercept (s) */
-double sys_error;              /* system standard error (s) */
-
-/*
- * Imported from ntp_proto.c module
- */
-extern double sys_rootdelay;   /* root delay */
-extern double sys_rootdispersion; /* root dispersion */
-extern s_char sys_precision;   /* local clock precision */
-extern struct peer *sys_peer;  /* system peer pointer */
-extern u_char sys_leap;                /* system leap bits */
-extern l_fp sys_reftime;       /* time at last update */
-
-/*
- * Imported from the library
- */
-extern double sys_maxfreq;     /* max frequency correction */
-
-/*
- * Imported from ntp_io.c module
- */
-extern struct interface *loopback_interface;
-
-/*
- * Imported from ntpd.c module
- */
-extern int debug;              /* global debug flag */
-
-/*
- * Imported from ntp_io.c module
- */
-extern u_long current_time;    /* like it says, in seconds */
-
-#if defined(KERNEL_PLL)
-/* Emacs cc-mode goes nuts if we split the next line... */
-#define MOD_BITS (MOD_OFFSET | MOD_MAXERROR | MOD_ESTERROR | \
-    MOD_STATUS | MOD_TIMECONST)
-#ifdef NTP_SYSCALLS_STD
-#ifdef DECL_SYSCALL
-extern int syscall     P((int, void *, ...));
-#endif /* DECL_SYSCALL */
-#endif /* NTP_SYSCALLS_STD */
-void pll_trap          P((int));
-#ifdef SIGSYS
-static struct sigaction sigsys;        /* current sigaction status */
-static struct sigaction newsigsys; /* new sigaction status */
-static sigjmp_buf env;         /* environment var. for pll_trap() */
-#endif /* SIGSYS */
-#endif /* KERNEL_PLL */
-
-/*
- * init_loopfilter - initialize loop filter data
- */
-void
-init_loopfilter(void)
-{
-       /*
-        * Initialize state variables. Initially, we expect no drift
-        * file, so set the state to S_NSET.
-        */
-       rstclock(S_NSET);
-}
-
-/*
- * local_clock - the NTP logical clock loop filter. Returns 1 if the
- * clock was stepped, 0 if it was slewed and -1 if it is hopeless.
- */
-int
-local_clock(
-       struct peer *peer,      /* synch source peer structure */
-       double fp_offset,       /* clock offset */
-       double epsil            /* jittter (square) */
-       )
-{
-       double mu;              /* interval since last update (s) */
-       double oerror;          /* previous error estimate */
-       double flladj;          /* FLL frequency adjustment (ppm) */
-       double plladj;          /* PLL frequency adjustment (ppm) */
-       double clock_frequency; /* clock frequency (ppm) adjustment */
-       double dtemp, etemp;    /* double temps */
-       int retval;             /* return value */
-#if defined(KERNEL_PLL)
-       struct timex ntv;
-#endif /* KERNEL_PLL */
-
-#ifdef DEBUG
-       if (debug)
-               printf(
-                   "local_clock: offset %.6f jitter %.6f state %d\n",
-                   fp_offset, SQRT(epsil), state);
-#endif
-       if (!ntp_enable)
-               return(0);
-
-       /*
-        * If the clock is way off, don't tempt fate by correcting it.
-        */
-       if (fabs(fp_offset) >= clock_panic && !correct_any) {
-               msyslog(LOG_ERR,
-                   "time error %.0f over %d seconds; set clock manually)",
-                   fp_offset, clock_panic);
-               return (-1);
-       }
-
-       /*
-        * If the clock has never been set, set it and  initialize the
-        * discipline parameters. We then switch to frequency mode to
-        * speed the inital convergence process.
-        */
-       if (state == S_NSET) {
-               step_systime(fp_offset);
-               NLOG(NLOG_SYNCEVENT|NLOG_SYSEVENT)
-                   msyslog(LOG_NOTICE, "time set %.6f s", fp_offset);
-               rstclock(S_TSET);
-               rstclock(S_FREQ);
-               return (1);
-       }
-
-       /*
-        * Update the phase error estimate.
-        */
-       oerror = sys_error;
-       dtemp = SQUARE(sys_error);
-       sys_error = SQRT(dtemp + (epsil - dtemp) / CLOCK_AVG);
-
-       /*
-        * If the offset exceeds clock_max and this is the first update
-        * after setting the clock, switch to frequency mode. This could
-        * happen either because the frequency error was too large or
-        * the kernel ignored the fractional second, as some do.
-        * Otherwise, unlock the loop and allow it to coast up to
-        * CLOCK_MINSTEP.
-        */
-       retval = 0;
-       clock_frequency = 0;
-       mu = current_time - last_time;
-       if (fabs(fp_offset) > clock_max) {
-               switch (state) {
-
-               /*
-                * In this state we are waiting for the initial
-                * frequency to converge. Ignore the large offset and
-                * sail on.
-                */
-               case S_FREQ:
-                       clock_offset = fp_offset;
-                       break;
-
-               /*
-                * In this state the time has been set at the last valid
-                * update and the residual error at that time set to
-                * zero. If following that we cruise outside the capture
-                * interval, assume a really bad frequency error and
-                * jump into frequency node.
-                */
-               case S_TSET:
-                       rstclock(S_FREQ);
-                       break;
-
-               /*
-                * In S_SYNC state. We ignore outlyers, unless they
-                * persist longer than CLOCK_MINSTEP (900 s). After
-                * that, ignore the first outlyer, since the next update
-                * could occur only after 900 s.
-                */
-               case S_SYNC:
-                       if (mu >= CLOCK_MINSTEP)
-                               rstclock(S_SPIK);
-                       return (0);
-
-               /*
-                * In S_SPIK state a step correction is necessary
-                * following timeout.
-                */
-               case S_SPIK:
-                       clock_frequency += (fp_offset - clock_offset) /
-                           mu;
-
-               /*
-                * We get here directly in S_FSET state and from above
-                * states. The clock is either reset or shaken and not
-                * stirred.
-                */
-               default:
-                       if (allow_set_backward) {
-                               step_systime(fp_offset);
-                               NLOG(NLOG_SYNCEVENT|NLOG_SYSEVENT)
-                                   msyslog(LOG_NOTICE, "time reset %.6f s",
-                                   fp_offset);
-                               rstclock(S_TSET);
-                               retval = 1;
-                       } else {
-                               NLOG(NLOG_SYNCEVENT|NLOG_SYSEVENT)
-                                   msyslog(LOG_NOTICE, "time slew %.6f s",
-                                   fp_offset);
-                               rstclock(S_FREQ);
-                               clock_offset = fp_offset;
-                       }
-                       break;
-               }
-       } else {
-               clock_offset = fp_offset;
-               switch (state) {
-
-               /*
-                * If this is the first update, initialize the
-                * discipline parameters and pretend we had just set the
-                * clock. We don't want to step the clock unless we have
-                * to.
-                */
-               case S_FSET:
-                       rstclock(S_TSET);
-                       last_offset = clock_offset;
-                       return (0);
-
-               /*
-                * Either the clock has just been set or the previous
-                * update was a spike and ignored. Since this update is
-                * not an outlyer, fold the tent and resume life.
-                */
-               case S_TSET:
-               case S_SPIK:
-                       rstclock(S_SYNC);
-
-               /*
-                * If the terminating condition in this state is
-                * satisfied, switch to S_SYNC state and run on to that
-                * state.
-                */
-               case S_FREQ:
-                       if (clock_stability < CLOCK_MAXSTAB &&
-                           clock_offset < CLOCK_PGATE * sys_error)
-                               rstclock(S_SYNC);
-
-               /*
-                * If the offset exceeds the previous time error
-                * estimate by CLOCK_SGATE and the interval since the
-                * last update is less than twice the poll interval,
-                * consider the update a popcorn spike and ignore it.
-                */
-               default:
-                       if (fabs(fp_offset - last_offset) >
-                           CLOCK_SGATE * oerror && mu <
-                           ULOGTOD(sys_poll + 1)) {
-#ifdef DEBUG
-                               if (debug)
-                                       printf("local_clock: popcorn %.6f %.6f\n",
-                                           fp_offset, last_offset);
-#endif
-                               last_offset = fp_offset;
-                               return (0);
-                       }
-                       break;
-               }
-       }
-
-       /*
-        * Compute the time offset and combined FLL and PLL frequency
-        * adjustments. In frequency mode, the frequency adjustment is
-        * computed directly. In other modes, the adjustment is
-        * conditioned on two weighting factors, one which limits the
-        * time constant determined from the Allan intercept, the other
-        * which limits the gain factor as a function of update
-        * interval. The net effect is to favor the PLL adjustments at
-        * the smaller update intervals and the FLL adjustments at the
-        * larger ones.
-        */
-       dtemp = max(mu, allan_xpt);
-       if (state == S_SYNC) {
-               etemp = min(max(0, mu - CLOCK_MINSEC) / CLOCK_ALLAN,
-                   1.);
-               flladj = clock_offset * etemp / (dtemp * CLOCK_AVG);
-       } else {
-               flladj = clock_offset / (dtemp * CLOCK_AVG);
-       }
-       dtemp = ULOGTOD(SHIFT_PLL + 2 + sys_poll);
-       plladj = clock_offset * mu / (dtemp * dtemp);
-       clock_frequency += flladj + plladj;
-
-       /*
-        * This code segment works when clock adjustments are made using
-        * precision time kernel support and the ntp_adjtime() system
-        * call. This support is available in Solaris 2.6 and later,
-        * Digital Unix 4.0 and later, FreeBSD, Linux and specially
-        * modified kernels for HP-UX 9 and Ultrix 4. In the case of the
-        * DECstation 5000/240 and Alpha AXP, additional kernel
-        * modifications provide a true microsecond clock and nanosecond
-        * clock, respectively.
-        */
-#if defined(KERNEL_PLL)
-       if (pll_control && kern_enable) {
-
-               /*
-                * We initialize the structure for the ntp_adjtime()
-                * system call. We have to convert everything to
-                * microseconds or nanoseconds first. Do not update the
-                * system variables if the ext_enable flag is set. In
-                * this case, the external clock driver will update the
-                * variables, which will be read later by the local
-                * clock driver. Afterwards, remember the time and
-                * frequency offsets for jitter and stability values and
-                * to update the drift file.
-                */
-               memset((char *)&ntv,  0, sizeof ntv);
-               if (ext_enable) {
-                       ntv.modes = MOD_STATUS;
-               } else {
-                       ntv.modes = MOD_BITS;
-                       if (clock_offset < 0)
-                               dtemp = -.5;
-                       else
-                               dtemp = .5;
-#ifdef STA_NANO
-                       if (pll_nano)
-                               ntv.offset = (int32)(clock_offset *
-                                   1e9 + dtemp);
-                       else
-#endif /* STA_NANO */
-                               ntv.offset = (int32)(clock_offset *
-                                   1e6 + dtemp);
-#ifdef STA_NANO
-                       ntv.constant = sys_poll;
-#else
-                       ntv.constant = sys_poll - 4;
-#endif /* STA_NANO */
-
-                       ntv.esterror = (u_int32)(sys_error * 1e6);
-                       ntv.maxerror = (u_int32)((sys_rootdelay / 2 +
-                           sys_rootdispersion) * 1e6);
-                       ntv.status = STA_PLL;
-
-                       /*
-                        * Set the leap bits in the status word.
-                        */
-                       if (sys_leap == LEAP_NOTINSYNC) {
-                               ntv.status |= STA_UNSYNC;
-                       } else if (calleapwhen(sys_reftime.l_ui) <
-                                   CLOCK_DAY) {
-                               if (sys_leap & LEAP_ADDSECOND)
-                                       ntv.status |= STA_INS;
-                               else if (sys_leap & LEAP_DELSECOND)
-                                       ntv.status |= STA_DEL;
-                       }
-
-                       /*
-                        * Switch to FLL mode if the poll interval is
-                        * greater than MAXDPOLL, so that the kernel
-                        * loop behaves as the daemon loop; viz.,
-                        * selects the FLL when necessary, etc. For
-                        * legacy only.
-                        */
-                       if (sys_poll > NTP_MAXDPOLL)
-                               ntv.status |= STA_FLL;
-               }
-
-               /*
-                * Wiggle the PPS bits according to the health of the
-                * prefer peer.
-                */
-               if (pll_status & STA_PPSSIGNAL)
-                       ntv.status |= STA_PPSFREQ;
-               if (pll_status & STA_PPSFREQ && pps_update)
-                       ntv.status |= STA_PPSTIME;
-
-               /*
-                * Update the offset and frequency from the kernel
-                * variables.
-                */
-               if (ntp_adjtime(&ntv) == TIME_ERROR) {
-                       if (ntv.status != pll_status)
-                               msyslog(LOG_ERR,
-                                   "kernel pll status change %x",
-                                   ntv.status);
-               }
-               pll_status = ntv.status;
-#ifdef STA_NANO
-               if (pll_nano)
-                       clock_offset = ntv.offset / 1e9;
-               else
-#endif /* STA_NANO */
-                       clock_offset = ntv.offset / 1e6;
-#ifdef STA_NANO
-               sys_poll = ntv.constant;
-#else
-               sys_poll = ntv.constant + 4;
-#endif /* STA_NANO */
-               clock_frequency = ntv.freq / 65536e6 - drift_comp;
-
-               /*
-                * If the kernel pps discipline is working, monitor its
-                * performance.
-                */
-               if (ntv.status & STA_PPSTIME) {
-                       if (!pps_control)
-                               NLOG(NLOG_SYSEVENT)msyslog(LOG_INFO,
-                                   "pps sync enabled");
-                       pps_control = current_time;
-#ifdef STA_NANO
-                       if (pll_nano)
-                               record_peer_stats(
-                                   &loopback_interface->sin,
-                                   ctlsysstatus(), ntv.offset / 1e9,
-                                   0., ntv.jitter / 1e9, 0.);
-                       else
-#endif /* STA_NANO */
-                               record_peer_stats(
-                                   &loopback_interface->sin,
-                                   ctlsysstatus(), ntv.offset / 1e6,
-                                   0., ntv.jitter / 1e6, 0.);
-               }
-       }
-#endif /* KERNEL_PLL */
-       /*
-        * Adjust the clock frequency and calculate the stability. If
-        * kernel support is available, we use the results of the kernel
-        * discipline instead of the PLL/FLL discipline. In this case,
-        * drift_comp is a sham and used only for updating the drift
-        * file and for billboard eye candy.
-        */
-       drift_comp += clock_frequency;
-       if (drift_comp > sys_maxfreq)
-               drift_comp = sys_maxfreq;
-       else if (drift_comp <= -sys_maxfreq)
-               drift_comp = -sys_maxfreq;
-       dtemp = SQUARE(clock_stability);
-       etemp = SQUARE(clock_frequency) - dtemp;
-       clock_stability = SQRT(dtemp + etemp / CLOCK_AVG);
-       allan_xpt = max(CLOCK_ALLAN, clock_stability * CLOCK_ADF);
-
-       /*
-        * In SYNC state, adjust the poll interval.
-        */
-       if (state == S_SYNC) {
-               if (clock_stability < CLOCK_MAXSTAB &&
-                   fabs(clock_offset) < CLOCK_PGATE * sys_error) {
-                       tc_counter += sys_poll;
-                       if (tc_counter > CLOCK_LIMIT) {
-                               tc_counter = CLOCK_LIMIT;
-                               if (sys_poll < peer->maxpoll) {
-                                       tc_counter = 0;
-                                       sys_poll++;
-                               }
-                       }
-               } else {
-                       if (tc_counter < -CLOCK_LIMIT) {
-                       tc_counter -= sys_poll << 1;
-                               tc_counter = -CLOCK_LIMIT;
-                               if (sys_poll > peer->minpoll) {
-                                       tc_counter = 0;
-                                       sys_poll--;
-                               }
-                       }
-               }
-       }
-
-       /*
-        * Update the system time variables.
-        */
-       last_time = current_time;
-       last_offset = clock_offset;
-       dtemp = peer->disp + SQRT(peer->variance + SQUARE(sys_error));
-       if ((peer->flags & FLAG_REFCLOCK) == 0 && dtemp < MINDISPERSE)
-               dtemp = MINDISPERSE;
-       sys_rootdispersion = peer->rootdispersion + dtemp;
-       (void)record_loop_stats();
-#ifdef DEBUG
-       if (debug)
-               printf(
-       "local_clock: mu %.0f allan %.0f fadj %.3f fll %.3f pll %.3f\n",
-                   mu, allan_xpt, clock_frequency * 1e6, flladj * 1e6,
-                   plladj * 1e6);
-#endif /* DEBUG */
-#ifdef DEBUG
-       if (debug)
-               printf(
-       "local_clock: jitter %.6f freq %.3f stab %.3f poll %d count %d\n",
-                   sys_error, drift_comp * 1e6, clock_stability * 1e6,
-                   sys_poll, tc_counter);
-#endif /* DEBUG */
-       return (retval);
-}
-
-
-/*
- * adj_host_clock - Called once every second to update the local clock.
- */
-void
-adj_host_clock(
-       void
-       )
-{
-       double adjustment;
-
-       /*
-        * Update the dispersion since the last update. In contrast to
-        * NTPv3, NTPv4 does not declare unsynchronized after one day,
-        * since the dispersion check serves this function. Also,
-        * since the poll interval can exceed one day, the old test
-        * would be counterproductive. Note we do this even with
-        * external clocks, since the clock driver will recompute the
-        * maximum error and the local clock driver will pick it up and
-        * pass to the common refclock routines. Very intricate.
-        */
-       sys_rootdispersion += CLOCK_PHI;
-
-       /*
-        * Declare PPS kernel unsync if the pps signal has not been
-        * heard for a few minutes.
-        */
-       if (pps_control && current_time - pps_control > PPS_MAXAGE) {
-               if (pps_control)
-                       NLOG(NLOG_SYSEVENT) /* conditional if clause */
-                           msyslog(LOG_INFO, "pps sync disabled");
-               pps_control = 0;
-       }
-       if (!ntp_enable)
-               return;
-
-       /*
-        * If the phase-lock loop is implemented in the kernel, we
-        * have no business going further.
-        */
-       if (pll_control && kern_enable)
-               return;
-
-       /*
-        * Intricate wrinkle for legacy only. If the local clock driver
-        * is in use and selected for synchronization, somebody else may
-        * tinker the adjtime() syscall. If this is the case, the driver
-        * is marked prefer and we have to avoid calling adjtime(),
-        * since that may truncate the other guy's requests.
-        */
-       if (sys_peer != 0) {
-               if (sys_peer->refclktype == REFCLK_LOCALCLOCK &&
-                   sys_peer->flags & FLAG_PREFER)
-                       return;
-       }
-       if (state == S_SYNC)
-               adjustment = clock_offset / ULOGTOD(SHIFT_PLL +
-                   sys_poll);
-       else
-               adjustment = clock_offset / ULOGTOD(sys_poll);
-       clock_offset -= adjustment;
-       adj_systime(adjustment + drift_comp);
-}
-
-
-/*
- * Clock state machine. Enter new state and set state variables.
- */
-static void
-rstclock(
-       int trans               /* new state */
-       )
-{
-       state = trans;
-       switch (state) {
-
-       /*
-        * Frequency mode. The clock has ben set, but the frequency has
-        * not yet been determined. Note that the Allan intercept is set
-        * insure the clock filter considers only the most recent
-        * measurements.
-        */ 
-       case S_FREQ:
-               sys_poll = NTP_MINDPOLL;
-               allan_xpt = NTP_MINDPOLL;
-               break;
-
-       /*
-        * Synchronized mode. Discipline the poll interval.
-        */
-       case S_SYNC:
-               sys_poll = NTP_MINDPOLL;
-               allan_xpt = CLOCK_ALLAN;
-               tc_counter = 0;
-               break;
-
-       /*
-        * Don't do anything in S_SPIK state; just continue from S_SYNC
-        * state.
-        */
-       case S_SPIK:
-               break;
-
-       /*
-        * S_NSET, S_FSET and S_TSET states. These transient states set
-        * the time reference for future frequency updates.
-        */
-       default:
-               sys_poll = NTP_MINDPOLL;
-               allan_xpt = CLOCK_ALLAN;
-               last_time = current_time;
-               last_offset = clock_offset = 0;
-               break;
-       }
-}
-
-
-/*
- * loop_config - configure the loop filter
- */
-void
-loop_config(
-       int item,
-       double freq
-       )
-{
-#if defined(KERNEL_PLL)
-       struct timex ntv;
-#endif /* KERNEL_PLL */
-
-#ifdef DEBUG
-       if (debug)
-               printf("loop_config: state %d freq %.3f\n", item, freq *
-                   1e6);
-#endif
-       switch (item) {
-
-           case LOOP_DRIFTINIT:
-           case LOOP_DRIFTCOMP:
-
-               /*
-                * The drift file is present and the initial frequency
-                * is available, so set the state to S_FSET
-                */
-               rstclock(S_FSET);
-               drift_comp = freq;
-               if (drift_comp > sys_maxfreq)
-                       drift_comp = sys_maxfreq;
-               if (drift_comp < -sys_maxfreq)
-                       drift_comp = -sys_maxfreq;
-#ifdef KERNEL_PLL
-               /*
-                * If the phase-lock code is implemented in the kernel,
-                * give the time_constant and saved frequency offset to
-                * the kernel. If not, no harm is done. Note the initial
-                * time constant is zero, but the first clock update
-                * will fix that.
-                */
-               memset((char *)&ntv, 0, sizeof ntv);
-               pll_control = 1;
-#ifdef MOD_NANO
-               ntv.modes = MOD_NANO;
-#endif /* MOD_NANO */
-#ifdef SIGSYS
-               newsigsys.sa_handler = pll_trap;
-               newsigsys.sa_flags = 0;
-               if (sigaction(SIGSYS, &newsigsys, &sigsys)) {
-                       msyslog(LOG_ERR,
-                           "sigaction() fails to save SIGSYS trap: %m");
-                       pll_control = 0;
-                       return;
-               }
-
-               /*
-                * Use sigsetjmp() to save state and then call
-                * ntp_adjtime(); if it fails, then siglongjmp() is used
-                * to return control
-                */
-               if (sigsetjmp(env, 1) == 0)
-                       (void)ntp_adjtime(&ntv);
-               if ((sigaction(SIGSYS, &sigsys,
-                   (struct sigaction *)NULL))) {
-                       msyslog(LOG_ERR,
-                           "sigaction() fails to restore SIGSYS trap: %m");
-                       pll_control = 0;
-                       return;
-               }
-#else /* SIGSYS */
-               if (ntp_adjtime(&ntv) < 0) {
-                       msyslog(LOG_ERR,
-                           "loop_config: ntp_adjtime() failed: %m");
-                       pll_control = 0;
-               }
-#endif /* SIGSYS */
-
-               /*
-                * If the kernel support is available and enabled,
-                * initialize the parameters, but only if the external
-                * clock is not present.
-                */
-               if (pll_control && kern_enable) {
-                       msyslog(LOG_NOTICE,
-                           "using kernel phase-lock loop %04x",
-                           ntv.status);
-#ifdef STA_NANO
-                       if (ntv.status & STA_NANO)
-                               pll_nano = 1;
-#endif /* STA_NANO */
-#ifdef STA_CLK
-
-                       if (ntv.status & STA_CLK) {
-                               ext_enable = 1;
-                       } else {
-                               ntv.modes = MOD_BITS | MOD_FREQUENCY;
-                               ntv.freq = (int32)(drift_comp *
-                                   65536e6);
-                               ntv.maxerror = MAXDISPERSE;
-                               ntv.esterror = MAXDISPERSE;
-                               ntv.status = STA_UNSYNC | STA_PLL;
-                               (void)ntp_adjtime(&ntv);
-                       }
-#else
-                       ntv.modes = MOD_BITS | MOD_FREQUENCY;
-                       ntv.freq = (int32)(drift_comp * 65536e6);
-                       ntv.maxerror = MAXDISPERSE;
-                       ntv.esterror = MAXDISPERSE;
-                       ntv.status = STA_UNSYNC | STA_PLL;
-                       (void)ntp_adjtime(&ntv);
-#endif /* STA_CLK */
-               }
-#endif /* KERNEL_PLL */
-       }
-}
-
-
-#if defined(KERNEL_PLL) && defined(SIGSYS)
-/*
- * _trap - trap processor for undefined syscalls
- *
- * This nugget is called by the kernel when the SYS_ntp_adjtime()
- * syscall bombs because the silly thing has not been implemented in
- * the kernel. In this case the phase-lock loop is emulated by
- * the stock adjtime() syscall and a lot of indelicate abuse.
- */
-RETSIGTYPE
-pll_trap(
-       int arg
-       )
-{
-       pll_control = 0;
-       siglongjmp(env, 1);
-}
-#endif /* KERNEL_PLL && SIGSYS */
index dc0a2dc2518df584957bf8fff67886a86f69d2b9..64dfb3ee15429adc6addab0c0ba75b04b9de6963 100644 (file)
@@ -8,7 +8,6 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <signal.h>
-#include <errno.h>
 # ifdef HAVE_SYS_IOCTL_H
 #  include <sys/ioctl.h>
 # endif
index 35f2ab33dd77deee00d1831bcd5a67b5b594f305..5cd58b0d6aa0a00088fbe6295fe54ddd17928f5d 100644 (file)
@@ -2,14 +2,13 @@
  * ntp_refclock - processing support for reference clocks
  */
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #include <stdio.h>
-#include <errno.h>
 #include <sys/types.h>
 #ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
+# include <sys/ioctl.h>
 #endif /* HAVE_SYS_IOCTL_H */
 
 #include "ntpd.h"
index 2dda53452adf0f3fa41901707db1d88acb13bde8..6e542ff4e719513a7074ba867d043cc2b58621b0 100644 (file)
@@ -8,7 +8,6 @@
 #include <sys/types.h>
 #include <stdio.h>
 #include <signal.h>
-#include <errno.h>
 #include <sys/time.h>
 
 #include "ntpd.h"
index 57ea5c47f771c6d402fb184c1aa32f8e245e9e95..9bc1a1d94f5e45f5ef7f7c01ef35b91665e74ed2 100644 (file)
@@ -6,7 +6,6 @@
 #endif
 
 #include <stdio.h>
-#include <errno.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <signal.h>
index b4b191d49cde6e920c1ee649fa933498a0e2960b..c53255a0a62b5c28379323e9f0c078e4613885d4 100644 (file)
@@ -6,7 +6,6 @@
 #endif
 
 #include <stdio.h>
-#include <errno.h>
 #include <ctype.h>
 #include <sys/types.h>
 # ifdef HAVE_SYS_IOCTL_H
index dc7db8214b9ce4d1009e4e8e618dc73ef1081bf2..65bdc8a0ee6604e00d775e86c77e00a0d6239ff7 100644 (file)
@@ -13,7 +13,6 @@
 # include <sys/stat.h>
 #endif
 #include <stdio.h>
-#include <errno.h>
 #ifndef SYS_WINNT
 # if !defined(VMS)     /*wjm*/
 #  include <sys/param.h>
index 0d64fb40fe79db55b069f0743b77b9b063a50e96..74a37dbbc575ccaaf2b092c1aa589f3084023c20 100644 (file)
@@ -8,7 +8,7 @@
 */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #if defined(REFCLOCK) && defined(CLOCK_DATUM)
 #include <stdio.h>
 #include <ctype.h>
 #include <sys/time.h>
-#include <sys/errno.h>
 
 #include "ntpd.h"
 #include "ntp_io.h"
 #include "ntp_refclock.h"
 #include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
 
 #if defined(HAVE_BSD_TTYS)
 #include <sgtty.h>
index 5df9b7703ac0fd73b756fcefda1f028af6265f63..be41b914268aed9355afb7d67fea4df61d0152a1 100644 (file)
@@ -40,7 +40,6 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <sys/time.h>
-#include <errno.h>
 
 #include "ntpd.h"
 #include "ntp_io.h"
index 48dca948070a2f3541262491810757b6648c5310..b90ee6f6f66838f4e6e05949e12516999a4b5ae1 100644 (file)
@@ -43,7 +43,6 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <sys/time.h>
-#include <errno.h>
 
 #include "ntpd.h"
 #include "ntp_io.h"
index b7201809e8e25adcc3deb79c11b83327b874c9e6..9042b9f010814dc1309bf66dfbf51b32d319b536 100644 (file)
@@ -52,7 +52,6 @@
  *
  */
 
-#include <errno.h>
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 670a3103c290d5b4d9927affa7ac285e02170c58..3f033ac2e9bf2a8f4a7d6bcc029cb4f3e0f72e9d 100644 (file)
@@ -86,9 +86,6 @@
 # include <time.h>
 #endif
 
-#include <sys/errno.h>
-extern int errno;
-
 #if !defined(STREAM) && !defined(HAVE_SYSV_TTYS) && !defined(HAVE_BSD_TTYS) && !defined(HAVE_TERMIOS)
 # include "Bletch:  Define one of {STREAM,HAVE_SYSV_TTYS,HAVE_TERMIOS}"
 #endif
index 1e884befb57b5c694a8c9c81fb8a33b916bacc58..4550ca60f1aa00f4ea105da4b23a8aaa1d33279a 100644 (file)
@@ -96,7 +96,6 @@ struct shmTime *getShmTime (int unit) {
 #ifndef SYS_WINNT
        extern char *sys_errlist[ ];
        extern int sys_nerr;
-       extern int errno;
        int shmid=0;
 
        assert (unit<10); /* MAXUNIT is 4, so should never happen */
index 765e2eab631c761a8a2ad91ac9f07598d3628e10..63b089a6f7aef38b4cc8e0ff5d6f6a43559c4751 100644 (file)
@@ -16,7 +16,6 @@
 #include <stdio.h>
 #include <signal.h>
 #include <ctype.h>
-#include <errno.h>
 #ifdef HAVE_POLL_H
 #include <poll.h>
 #endif
index 1decb9ee1f7823124762672e248a86760acc0446..56f653932c2dc7c3a5de88316760c7587ef07633 100644 (file)
 #include <stdio.h>
 #include <signal.h>
 #include <ctype.h>
-#include <errno.h>
 #include <sys/time.h>
 
-
 #include "ntp_fp.h"
 #include "ntp.h"
 #include "ntp_io.h"
index e97b6bc3554d1a43e243037c3147959c62373053..71eb886e017c13a8ee75447d95412e71a805e9c2 100644 (file)
 #include <stdio.h>
 #include <signal.h>
 #include <ctype.h>
-#include <errno.h>
 #ifndef SYS_WINNT
 # include <netdb.h>
 # include <sys/signal.h>
index 03964c23a3a7b5409718bf648952f732f91ded3d..93622c198d77d282e216f832f092f9acf03fdec5 100644 (file)
@@ -11,7 +11,6 @@
 #include <stdio.h>
 #include <signal.h>
 #include <ctype.h>
-#include <errno.h>
 #include <netdb.h>
 #include <sys/types.h>
 #include <sys/signal.h>
index b777117d5233052bf95eef67aa136f9c31c0c096..3277c4a232171664f0b53f75bed22ef0642c22a1 100644 (file)
  * written consent of the author.
  */
 
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <unistd.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <signal.h>
-#include <errno.h>
 #include <syslog.h>
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
 /*
  * NTP compilation environment
  */
index e3a64c9dd23aa0a3374c3448a5f1a487d0d0967f..2dcbfe092956475dc447d071d716d0ae97fe44e9 100644 (file)
@@ -17,8 +17,8 @@
 #include <ctype.h>
 #include <sys/time.h>
 #include <signal.h>
-#include <errno.h>
 #include <setjmp.h>
+
 #include "ntp_fp.h"
 #include "ntp_unixtime.h"
 #include "ntp_syscall.h"