From 5251675b440ca947563b0e5a0b337d2ede38ec6d Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Wed, 20 Sep 2023 11:24:27 +0800 Subject: [PATCH] fix: windows gettimeofday --- utils/TSZ/sz/src/sz.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/utils/TSZ/sz/src/sz.c b/utils/TSZ/sz/src/sz.c index a17c2022c9..476cc23a06 100644 --- a/utils/TSZ/sz/src/sz.c +++ b/utils/TSZ/sz/src/sz.c @@ -162,8 +162,23 @@ void SZ_Finalize() #ifdef WINDOWS #include -int gettimeofday(struct timeval *tv, struct timezone *tz); - +int gettimeofday(struct timeval *tp, void *tzp) { + time_t clock; + struct tm tm; + SYSTEMTIME wtm; + GetLocalTime(&wtm); + tm.tm_year = wtm.wYear - 1900; + tm.tm_mon = wtm.wMonth - 1; + tm.tm_mday = wtm.wDay; + tm.tm_hour = wtm.wHour; + tm.tm_min = wtm.wMinute; + tm.tm_sec = wtm.wSecond; + tm. tm_isdst = -1; + clock = mktime(&tm); + tp->tv_sec = clock; + tp->tv_usec = wtm.wMilliseconds * 1000; + return 0; +} #else #include #endif