]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Treat zero counter as indication of precise system time in Windows
authorDave Hart <hart@ntp.org>
Tue, 20 Mar 2012 06:03:15 +0000 (06:03 +0000)
committerDave Hart <hart@ntp.org>
Tue, 20 Mar 2012 06:03:15 +0000 (06:03 +0000)
  PPSAPI helper function pps_ntp_timestamp_from_counter(), enabling
  PPSAPI providers to use the Windows 8 precise clock directly.

bk: 4f681da3R3sXoD6JALttpSHBWAFGTw

ChangeLog
ports/winnt/include/clockstuff.h
ports/winnt/ntpd/nt_clockstuff.c

index 07b60973a6de779d05073e8329ae9eaa291e4829..1197370523a80b484e071282301ec363beb20f5f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+* Treat zero counter as indication of precise system time in Windows
+  PPSAPI helper function pps_ntp_timestamp_from_counter(), enabling
+  PPSAPI providers to use the Windows 8 precise clock directly.
 (4.2.7p264) 2012/03/14 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 2160] Note if leapseconds file is past its prime.
 * Use GetSystemTimePreciseAsFileTime() on Windows 8.
index 3c1100b4969f1f3a6bdcf4504ada6cc716cc72ce..df85699350946fc470e94f4c1908672bd688797e 100644 (file)
@@ -41,13 +41,4 @@ extern PGSTAFT pGetSystemTimePreciseAsFileTime;
 
 void lock_thread_to_processor(HANDLE);
 
-#ifdef HAVE_PPSAPI
-/*
- * ntp_timestamp_from_counter provides an interface for 
- * serialpps.sys counterstamps to be converted to 
- * interpolated timestamps.
- */
-extern void ntp_timestamp_from_counter(l_fp *, ULONGLONG, ULONGLONG);
-#endif
-
 #endif
index fd6f6c35e79205590fedb24b4215e706b1f330c9..53c5415aeea73b330943188f001fefd24e8242d0 100644 (file)
@@ -1183,6 +1183,9 @@ lock_thread_to_processor(HANDLE thread)
 
 
 #ifdef HAVE_PPSAPI
+static inline void ntp_timestamp_from_counter(l_fp *, ULONGLONG,
+                                             ULONGLONG);
+
 /*
  * helper routine for serial PPS which returns QueryPerformanceCounter
  * timestamp and needs to interpolate it to an NTP timestamp.
@@ -1204,6 +1207,7 @@ pps_ntp_timestamp_from_counter(
 }
 
 
+static inline 
 void 
 ntp_timestamp_from_counter(
        l_fp *result, 
@@ -1225,27 +1229,9 @@ ntp_timestamp_from_counter(
                }
 
                InterpTimestamp = interp_time(Counterstamp + QPC_offset, FALSE);
-
-#ifdef DEBUG
-               /* sanity check timestamp is within 1 minute of now */
-               GetSystemTimeAsFileTime(&Now.ft);
-               Now.ull -= InterpTimestamp;
-               if (debug &&
-                   Now.ll > 60 * HECTONANOSECONDS || 
-                   Now.ll < -60 * HECTONANOSECONDS) {
-                       DPRINTF(1, ("ntp_timestamp_from_counter interpolated time %.6fs from current\n",
-                                       Now.ll / (double)HECTONANOSECONDS));
-                       DPRINTF(1, ("interpol time %llx from  %llx + %llx\n",
-                                       InterpTimestamp, Counterstamp,
-                                       QPC_offset));
-                       msyslog(LOG_ERR,
-                               "ntp_timestamp_from_counter interpolated time %.6fs from current\n",
-                               Now.ll / (double)HECTONANOSECONDS);
-                       exit(-1);
-               }
-#endif
        } else {  /* ! winnt_use_interpolation */
-               if (NULL != pGetSystemTimePreciseAsFileTime) {
+               if (NULL != pGetSystemTimePreciseAsFileTime &&
+                   0 != Counterstamp) {
                        QueryPerformanceCounter(&Ctr.li);
                        (*pGetSystemTimePreciseAsFileTime)(&Now.ft);
                        CtrDelta = Ctr.ull - Counterstamp;
@@ -1257,23 +1243,6 @@ ntp_timestamp_from_counter(
                        InterpTimestamp = Timestamp;
                        GetSystemTimeAsFileTime(&Now.ft);
                }
-#ifdef DEBUG
-               /* sanity check timestamp is within 1 minute of now */
-               Now.ull -= InterpTimestamp;
-               if (debug &&
-                   Now.ll > 60 * HECTONANOSECONDS || 
-                   Now.ll < -60 * HECTONANOSECONDS) {
-                       DPRINTF(1, ("ntp_timestamp_from_counter serial driver %s time %.6fs from current\n",
-                                   (NULL == pGetSystemTimePreciseAsFileTime)
-                                       ? "system"
-                                       : "counter",
-                                   Now.ll / (double)HECTONANOSECONDS));
-                       msyslog(LOG_ERR,
-                               "ntp_timestamp_from_counter serial driver system time %.6fs from current\n",
-                               Now.ll / (double)HECTONANOSECONDS);
-                       exit(-1);
-               }
-#endif
        }
 
        /* convert from 100ns units to NTP fixed point format */