summaryrefslogtreecommitdiffstats
path: root/libfreerdp/utils/stopwatch.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:25:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:25:12 +0000
commit827a4c3faa27e0c186452585b15094eee1119085 (patch)
treee6a08b0c767863d66f7d4a9de80db5edc7db29be /libfreerdp/utils/stopwatch.c
parentReleasing progress-linux version 3.3.0+dfsg1-1~progress7.99u1. (diff)
downloadfreerdp3-827a4c3faa27e0c186452585b15094eee1119085.tar.xz
freerdp3-827a4c3faa27e0c186452585b15094eee1119085.zip
Merging upstream version 3.5.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--libfreerdp/utils/stopwatch.c28
1 files changed, 4 insertions, 24 deletions
diff --git a/libfreerdp/utils/stopwatch.c b/libfreerdp/utils/stopwatch.c
index 3989638..70b60b3 100644
--- a/libfreerdp/utils/stopwatch.c
+++ b/libfreerdp/utils/stopwatch.c
@@ -22,38 +22,18 @@
#include <stdio.h>
#include <stdlib.h>
+#include <winpr/sysinfo.h>
#include <freerdp/utils/stopwatch.h>
-#ifdef _WIN32
-LARGE_INTEGER stopwatch_freq = { 0 };
-#else
-#include <sys/time.h>
-#endif
-
static void stopwatch_set_time(UINT64* usecs)
{
-#ifdef _WIN32
- LARGE_INTEGER perfcount;
- QueryPerformanceCounter(&perfcount);
- *usecs = (perfcount.QuadPart * 1000000) / stopwatch_freq.QuadPart;
-#else
- struct timeval tv;
- gettimeofday(&tv, NULL);
- *usecs = tv.tv_sec * 1000000 + tv.tv_usec;
-#endif
+ const UINT64 ns = winpr_GetTickCount64NS();
+ *usecs = WINPR_TIME_NS_TO_US(ns);
}
STOPWATCH* stopwatch_create(void)
{
- STOPWATCH* sw = NULL;
-#ifdef _WIN32
- if (stopwatch_freq.QuadPart == 0)
- {
- QueryPerformanceFrequency(&stopwatch_freq);
- }
-#endif
-
- sw = (STOPWATCH*)malloc(sizeof(STOPWATCH));
+ STOPWATCH* sw = (STOPWATCH*)calloc(1, sizeof(STOPWATCH));
if (!sw)
return NULL;
stopwatch_reset(sw);