Fix time_update() to compile and work on MinGW.

This commit is contained in:
Jason Evans 2016-02-20 23:45:22 -08:00
parent 56139dc403
commit fd9cd7a6cc

View File

@ -161,12 +161,15 @@ time_update(struct timespec *time)
time_copy(&old_time, time); time_copy(&old_time, time);
#ifdef _WIN32 #ifdef _WIN32
{
FILETIME ft; FILETIME ft;
uint64_t ticks; uint64_t ticks;
GetSystemTimeAsFileTime(&ft); GetSystemTimeAsFileTime(&ft);
ticks = (ft.dwHighDateTime << 32) | ft.dWLowDateTime; ticks = (((uint64_t)ft.dwHighDateTime) << 32) |
time->tv_sec = ticks / 10000; ft.dwLowDateTime;
time->tv_nsec = ((ticks % 10000) * 100); time->tv_sec = ticks / 10000000;
time->tv_nsec = ((ticks % 10000000) * 100);
}
#elif JEMALLOC_CLOCK_GETTIME #elif JEMALLOC_CLOCK_GETTIME
if (sysconf(_SC_MONOTONIC_CLOCK) > 0) if (sysconf(_SC_MONOTONIC_CLOCK) > 0)
clock_gettime(CLOCK_MONOTONIC, time); clock_gettime(CLOCK_MONOTONIC, time);