From 8d22984b6f82f044af9615e86ef2942a0902fbc1 Mon Sep 17 00:00:00 2001 From: mayong Date: Fri, 9 Sep 2022 14:58:15 +0800 Subject: [PATCH] Add win_func.h --- include/win_func.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 include/win_func.h diff --git a/include/win_func.h b/include/win_func.h new file mode 100644 index 0000000..90206f3 --- /dev/null +++ b/include/win_func.h @@ -0,0 +1,28 @@ +#include +#ifdef WIN32 +#include +#else +#include +#endif +#ifdef WIN32 +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); +} +#endif \ No newline at end of file