winpr: add high-precision GetTickCountPrecise for Windows.
authorVic Lee <llyzs.vic@gmail.com>
Thu, 11 Jun 2015 07:11:19 +0000 (15:11 +0800)
committerVic Lee <llyzs.vic@gmail.com>
Thu, 11 Jun 2015 07:11:19 +0000 (15:11 +0800)
winpr/include/winpr/sysinfo.h
winpr/libwinpr/sysinfo/sysinfo.c

index 120009a..a72297f 100644 (file)
@@ -295,6 +295,8 @@ WINPR_API ULONGLONG GetTickCount64(void);
 
 #endif
 
+WINPR_API DWORD GetTickCountPrecise(void);
+
 WINPR_API BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature);
 
 /* extended flags */
index 1aa7d87..8c7234b 100644 (file)
@@ -678,6 +678,21 @@ BOOL IsProcessorFeaturePresent(DWORD ProcessorFeature)
 
 #endif //_WIN32
 
+DWORD GetTickCountPrecise(void)
+{
+#ifdef _WIN32
+       LARGE_INTEGER freq;
+       LARGE_INTEGER current;
+
+       QueryPerformanceFrequency(&freq);
+       QueryPerformanceCounter(&current);
+
+       return (DWORD) (current.QuadPart * 1000LL / freq.QuadPart);
+#else
+       return GetTickCount();
+#endif
+}
+
 BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature)
 {
        BOOL ret = FALSE;