+* 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.
#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.
}
+static inline
void
ntp_timestamp_from_counter(
l_fp *result,
}
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;
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 */