]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Weed-whack NANO stuff from Dave Mills
authorHarlan Stenn <stenn@ntp.org>
Fri, 28 Oct 2005 23:05:28 +0000 (19:05 -0400)
committerHarlan Stenn <stenn@ntp.org>
Fri, 28 Oct 2005 23:05:28 +0000 (19:05 -0400)
bk: 4362aeb8NBXtcCYvKJXu0TAYxMndlg

ntpd/ntp_loopfilter.c

index 5c7bc8ea96b0ee7214acece50fa128a59e65a667..2527bd7dd54053b0c797c50cb378b370090936af 100644 (file)
  * support is used as described above; if false, the kernel is bypassed
  * entirely and the daemon PLL used instead.
  *
+ * There have been three versions of the kernel discipline code. The
+ * first (microkernel) now in Solaris discipilnes the microseconds. The
+ * second and third (nanokernel) disciplines the clock in nanoseconds.
+ * These versions are identifed if the symbol STA_PLL is present in the
+ * header file /usr/include/sys/timex.h. The third and current version
+ * includes TAI offset and is identified by the symbol NTP_API with
+ * value 4.
+ *
  * Each update to a prefer peer sets pps_stratum 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
@@ -129,7 +137,6 @@ static void rstclock P((int, u_long, double)); /* transition function */
 #ifdef KERNEL_PLL
 struct timex ntv;              /* kernel API parameters */
 int    pll_status;             /* status bits for kernel pll */
-int    pll_nano;               /* nanosecond kernel switch */
 #endif /* KERNEL_PLL */
 
 /*
@@ -502,7 +509,7 @@ local_clock(
                                break;
                        }
                }
-#ifdef STA_NANO
+#if defined(STA_NANO) && NTP_API == 4
                if (pll_control && kern_enable && sys_tai == 0) {
                        memset(&ntv, 0, sizeof(ntv));
                        ntv.modes = MOD_TAI;
@@ -556,15 +563,15 @@ local_clock(
                                dtemp = -.5;
                        else
                                dtemp = .5;
-                       if (pll_nano) {
-                               ntv.offset = (int32)(clock_offset *
-                                   1e9 + dtemp);
-                               ntv.constant = sys_poll;
-                       } else {
-                               ntv.offset = (int32)(clock_offset *
-                                   1e6 + dtemp);
-                               ntv.constant = sys_poll - 4;
-                       }
+#ifdef STA_NANO
+                       ntv.offset = (int32)(clock_offset * 1e9 +
+                           dtemp);
+                       ntv.constant = sys_poll;
+#else /* STA_NANO */
+                       ntv.offset = (int32)(clock_offset * 1e6 +
+                           dtemp);
+                       ntv.constant = sys_poll - 4;
+#endif /* STA_NANO */
                        if (clock_frequency != 0) {
                                ntv.modes |= MOD_FREQUENCY;
                                ntv.freq = (int32)((clock_frequency +
@@ -647,10 +654,11 @@ local_clock(
                                    ntv.status);
                }
                pll_status = ntv.status;
-               if (pll_nano)
-                       clock_offset = ntv.offset / 1e9;
-               else
-                       clock_offset = ntv.offset / 1e6;
+#ifdef STA_NANO
+               clock_offset = ntv.offset / 1e9;
+#else /* STA_NANO */
+               clock_offset = ntv.offset / 1e6;
+#endif /* STA_NANO */
                clock_frequency = ntv.freq / 65536e6 - drift_comp;
                flladj = plladj = 0;
 
@@ -659,10 +667,11 @@ local_clock(
                 */
                if (ntv.status & STA_PPSTIME) {
                        pps_control = current_time;
-                       if (pll_nano)
-                               clock_jitter = ntv.jitter / 1e9;
-                       else
-                               clock_jitter = ntv.jitter / 1e6;
+#ifdef STA_NANO
+                       clock_jitter = ntv.jitter / 1e9;
+#else /* STA_NANO */
+                       clock_jitter = ntv.jitter / 1e6;
+#endif /* STA_NANO */
                }
        }
 #endif /* KERNEL_PLL */
@@ -882,7 +891,7 @@ loop_config(
                memset(&ntv, 0, sizeof(ntv));
 #ifdef STA_NANO
                ntv.modes = MOD_BITS | MOD_NANO;
-#else
+#else /* STA_NANO */
                ntv.modes = MOD_BITS;
 #endif /* STA_NANO */
                ntv.maxerror = MAXDISPERSE;
@@ -920,8 +929,6 @@ loop_config(
                pll_status = ntv.status;
                if (pll_control) {
 #ifdef STA_NANO
-                       if (pll_status & STA_NANO)
-                               pll_nano = 1;
                        if (pll_status & STA_CLK)
                                ext_enable = 1;
 #endif /* STA_NANO */