diff options
Diffstat (limited to 'facetracknoir/timer.hpp')
-rw-r--r-- | facetracknoir/timer.hpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/facetracknoir/timer.hpp b/facetracknoir/timer.hpp index d8c15181..623836db 100644 --- a/facetracknoir/timer.hpp +++ b/facetracknoir/timer.hpp @@ -1,24 +1,24 @@ #pragma once #include <time.h> #if defined (_WIN32) -#include <windows.h> +# include <windows.h> +# define CLOCK_MONOTONIC 0 static inline void clock_gettime(int, struct timespec* ts) { - static LARGE_INTEGER freq = 0; + static LARGE_INTEGER freq; - if (!freq) + if (!freq.QuadPart) (void) QueryPerformanceFrequency(&freq); - freq.QuadPart /= 1000000; - LARGE_INTEGER d; (void) QueryPerformanceCounter(&d); - d.QuadPart = d.QuadPart / freq.QuadPart; + d.QuadPart *= 1000000000L; + d.QuadPart /= freq.QuadPart; - ts->tv_sec = d.QuadPart / 1000000; - ts->tv_nsec = d.QuadPart % 1000000; + ts->tv_sec = d.QuadPart / 1000000000L; + ts->tv_nsec = d.QuadPart % 1000000000L; } #else |