Calculation of usec value is incorrect - 'ticks' is not adjusted for epoch, whereas 'sec' has been, also subtraction has mismatched units - ticks in 100ns and sec * USEC_PER_SEC in usecs.

On 14/02/2021 01:20, Dmitry Kozlyuk wrote:
+       GetSystemTimePreciseAsFileTime(&ft);
+       ticks = ((uint64_t)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
+       sec = (ticks - EPOCH) / (TICKS_PER_USEC * USEC_PER_SEC);
+       now->sec = sec;
+       now->usec = (ticks - sec * USEC_PER_SEC) / TICKS_PER_USEC;

Reply via email to