commit 0c31de550ba49fe36d43568209d6cee49ef54a2a
parent 86e0e5f3d9ec142d140c6d718564f8d7240a3994
Author: finwo <finwo@pm.me>
Date: Sun, 18 Feb 2024 23:29:23 +0100
Using win32ports for gettimeofday
Diffstat:
2 files changed, 4 insertions(+), 24 deletions(-)
diff --git a/package.ini b/package.ini
@@ -1,3 +1,5 @@
+[dependencies]
+win32ports/sys_time_h=https://raw.githubusercontent.com/finwo/dep-repository/main/win32ports/sys_time_h/package.ini
[export]
config.mk=config.mk
include/finwo/benchmark.h=src/benchmark.h
diff --git a/src/benchmark.c b/src/benchmark.c
@@ -4,30 +4,8 @@
#include <string.h>
#if defined(_WIN32) || defined(_WIN64)
-#include <Windows.h>
-#include <winsock2.h> // For struct_timeval
-
-int gettimeofday(struct timeval * tp, struct timezone * tzp) {
- // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
- // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
- // until 00:00:00 January 1, 1970
- static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
-
- SYSTEMTIME system_time;
- FILETIME file_time;
- uint64_t time;
-
- GetSystemTime( &system_time );
- SystemTimeToFileTime( &system_time, &file_time );
- time = ((uint64_t)file_time.dwLowDateTime ) ;
- time += ((uint64_t)file_time.dwHighDateTime) << 32;
-
- tp->tv_sec = (long) ((time - EPOCH) / 10000000L);
- tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
- return 0;
-}
-
-#else // _WIN32 || _WIN64
+#include "win32ports/time.h"
+#else
#include <sys/time.h>
#endif