shims: correct _dispatch_get_nanoseconds on Windows
The NT time representation uses 1/1/1601 as epoch as opposed to Unix
which uses 1/1/1970.  Account for the offset in the calculation.  This
corrects the calculation of now.
@@ -108,13 +108,14 @@ _dispatch_get_nanoseconds(void)
dispatch_assume_zero(clock_gettime(CLOCK_REALTIME, &ts));
return _dispatch_timespec_to_nano(ts);
#elif defined(_WIN32)
+ static const uint64_t kNTToUNIXBiasAdjustment = 11644473600 * NSEC_PER_SEC;
// FILETIME is 100-nanosecond intervals since January 1, 1601 (UTC).
FILETIME ft;
ULARGE_INTEGER li;
GetSystemTimeAsFileTime(&ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
- return li.QuadPart * 100ull;
+ return li.QuadPart * 100ull - kNTToUNIXBiasAdjustment;
#else
struct timeval tv;
dispatch_assert_zero(gettimeofday(&tv, NULL));
