diff --git a/src/win32/sys_time.c b/src/win32/sys_time.c index ea7c25dda..08da60b85 100644 --- a/src/win32/sys_time.c +++ b/src/win32/sys_time.c @@ -1,20 +1,33 @@ -#include -#include - #include "sys_time.h" +#ifndef STLINK_HAVE_SYS_TIME_H + +#include + /* Simple gettimeofday implementation without converting Windows time to Linux time */ int gettimeofday(struct timeval *tv, struct timezone *tz) { FILETIME ftime; ULARGE_INTEGER ulint; + static int tzflag = 0; + + if(NULL != tv) { + GetSystemTimeAsFileTime(&ftime); + ulint.LowPart = ftime.dwLowDateTime; + ulint.HighPart = ftime.dwHighDateTime; - GetSystemTimeAsFileTime(&ftime); - ulint.LowPart = ftime.dwLowDateTime; - ulint.HighPart = ftime.dwHighDateTime; + tv->tv_sec = (long)(ulint.QuadPart / 10000000L); + tv->tv_usec = (long)(ulint.QuadPart % 10000000L); + } - tv->tv_sec = (long)(ulint.QuadPart / 10000000L); - tv->tv_usec = (long)(ulint.QuadPart % 10000000L); + if(NULL != tz) { + if (!tzflag) { + _tzset(); + tzflag++; + } + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } return 0; - (void)tz; } +#endif //STLINK_HAVE_SYS_TIME_H diff --git a/src/win32/sys_time.h b/src/win32/sys_time.h index 87c3a42fd..39f97f739 100644 --- a/src/win32/sys_time.h +++ b/src/win32/sys_time.h @@ -5,10 +5,7 @@ #include #else -struct timeval { - long tv_sec; - long tv_usec; -}; +#include struct timezone { int tz_minuteswest;