]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
MSVC: xz: Use GetTickCount64() to implement mytime_now().
authorLasse Collin <lasse.collin@tukaani.org>
Tue, 5 Sep 2023 18:33:35 +0000 (21:33 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Fri, 22 Sep 2023 17:00:38 +0000 (20:00 +0300)
It's available since Windows Vista.

src/xz/mytime.c

index 9eff566f9f47691ed3d842350d9e1052d0644129..4c13d37727812db6a4925dc2f1db5b79353c8c70 100644 (file)
@@ -12,7 +12,9 @@
 
 #include "private.h"
 
-#ifdef HAVE_CLOCK_GETTIME
+#if defined(_MSC_VER)
+       // Nothing
+#elif defined(HAVE_CLOCK_GETTIME)
 #      include <time.h>
 #else
 #      include <sys/time.h>
@@ -45,7 +47,11 @@ static uint64_t next_flush;
 static uint64_t
 mytime_now(void)
 {
-#ifdef HAVE_CLOCK_GETTIME
+#if defined(_MSC_VER)
+       // NOTE: This requires Windows Vista or later.
+       return GetTickCount64();
+
+#elif defined(HAVE_CLOCK_GETTIME)
        struct timespec tv;
 
 #      ifdef HAVE_CLOCK_MONOTONIC
@@ -60,6 +66,7 @@ mytime_now(void)
 #      endif
 
        return (uint64_t)tv.tv_sec * 1000 + (uint64_t)(tv.tv_nsec / 1000000);
+
 #else
        struct timeval tv;
        gettimeofday(&tv, NULL);