summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-06-11 21:10:22 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-06-11 21:10:22 +0200
commit7454496476ba17ea622781d280606161581c9544 (patch)
tree34473837e9914175ad99334d5344d8c7b3a70e30
parent3d6ab158aec3569a13fb790d100f1ce3286772ca (diff)
Fix Windows performance counters
-rw-r--r--facetracknoir/timer.hpp16
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