aboutsummaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/misc.c b/src/misc.c
index f276020..d6f9e64 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -4,9 +4,23 @@
#include <time.h>
#if defined(_WIN32)
-#error GetCurrentTime implementation missing
+#include "win32.h"
+int64_t MqttGetCurrentTime()
+{
+ static volatile long once = 0;
+ static LARGE_INTEGER frequency;
+ LARGE_INTEGER counter;
+ if (InterlockedCompareExchange(&once, 1, 0) == 0)
+ {
+ QueryPerformanceFrequency(&frequency);
+ }
+ QueryPerformanceCounter(&counter);
+ counter.QuadPart *= 1000;
+ counter.QuadPart /= frequency.QuadPart;
+ return counter.QuadPart;
+}
#else
-int64_t GetCurrentTime()
+int64_t MqttGetCurrentTime()
{
struct timespec t;