From 7454496476ba17ea622781d280606161581c9544 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 11 Jun 2014 21:10:22 +0200 Subject: Fix Windows performance counters --- facetracknoir/timer.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'facetracknoir/timer.hpp') 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 #if defined (_WIN32) -#include +# include +# 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 -- cgit v1.2.3