From 0d0a0c2f8aa1eb2dfce3830b931a18d14662c8aa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 24 Oct 2015 16:03:28 +0200 Subject: timer: guard against overflow on win32 --- opentrack-compat/timer.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/opentrack-compat/timer.hpp b/opentrack-compat/timer.hpp index 1d424832..f0741295 100644 --- a/opentrack-compat/timer.hpp +++ b/opentrack-compat/timer.hpp @@ -24,9 +24,7 @@ static inline void opentrack_clock_gettime(int, struct timespec* ts) (void) QueryPerformanceCounter(&d); - long long part = d.QuadPart; - part *= 1000000000ULL; - part /= freq.QuadPart; + long long part = d.QuadPart / ((long double)freq.QuadPart) * 1000000000.L; ts->tv_sec = part / 1000000000ULL; ts->tv_nsec = part % 1000000000ULL; -- cgit v1.2.3