From 86155ef1baf506c4b8d7bb30e25fc0ef1eb956b8 Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Fri, 16 May 2014 12:16:22 +0300 Subject: [PATCH] Added windows specific timing macros for thread debugging --- src/threads.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/threads.h b/src/threads.h index 4448e8cd..3dd9b58e 100644 --- a/src/threads.h +++ b/src/threads.h @@ -40,11 +40,19 @@ //TODO: we assume !GCC => Windows... this may be bad #include +#ifdef _DEBUG +#define CLOCK_T struct _FILETIME +#define GET_TIME(clock_t) GetSystemTimeAsFileTime(clock_t) +// _FILETIME has 32bit low and high part of 64bit 100ns resolution timestamp (since 12:00 AM January 1, 1601) +#define CLOCK_T_AS_DOUBLE(ts) ((double)(((uint64_t)(ts).dwHighDateTime)<<32 | (uint64_t)(ts).dwLowDateTime) / (double)10000000L) +#define CLOCK_T_DIFF(start, stop) ((double)((((uint64_t)(stop).dwHighDateTime)<<32 | (uint64_t)(stop).dwLowDateTime) - \ + (((uint64_t)(start).dwHighDateTime)<<32 | (uint64_t)(start).dwLowDateTime)) / (double)10000000L) +#endif + #define ATOMIC_INC(ptr) InterlockedIncrement((volatile LONG*)ptr) #define ATOMIC_DEC(ptr) InterlockedDecrement((volatile LONG*)ptr) #define SLEEP() Sleep(0) - #endif //__GNUC__ #endif //THREADS_H_