diff --git a/apps/openssl/compat/poll_win.c b/apps/openssl/compat/poll_win.c index c9422b91..f0b2b041 100644 --- a/apps/openssl/compat/poll_win.c +++ b/apps/openssl/compat/poll_win.c @@ -248,12 +248,12 @@ poll(struct pollfd *pfds, nfds_t nfds, int timeout_ms) timespent_ms = 0; wait_rc = WAIT_FAILED; + looptime_ms = (timeout_ms > 100 || timeout_ms == -1) ? 100 : timeout_ms; if (timeout_ms < 0) timeout_ms = INFINITE; - looptime_ms = timeout_ms > 100 ? 100 : timeout_ms; do { - struct timeval tv; + TIMEVAL tv; tv.tv_sec = 0; tv.tv_usec = looptime_ms * 1000; int handle_signaled = 0; diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 7efb143e..6134ee5f 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -750,7 +750,7 @@ endif() if(WIN32) set(CRYPTO_SRC ${CRYPTO_SRC} compat/posix_win.c) - set(EXTRA_EXPORT ${EXTRA_EXPORT} gettimeofday) + set(EXTRA_EXPORT ${EXTRA_EXPORT} gettimeofday=libressl_gettimeofday) set(EXTRA_EXPORT ${EXTRA_EXPORT} getuid) set(EXTRA_EXPORT ${EXTRA_EXPORT} posix_perror) set(EXTRA_EXPORT ${EXTRA_EXPORT} posix_fopen) diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index b3a46872..7a43d80a 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c @@ -9,6 +9,8 @@ #define NO_REDEF_POSIX_FUNCTIONS +#include + #include #include @@ -303,7 +305,7 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp) time = ((uint64_t)file_time.dwLowDateTime); time += ((uint64_t)file_time.dwHighDateTime) << 32; - tp->tv_sec = (long)((time - EPOCH) / 10000000L); + tp->tv_sec = (long long)((time - EPOCH) / 10000000L); tp->tv_usec = (long)(system_time.wMilliseconds * 1000); return 0; } diff --git a/include/compat/sys/time.h b/include/compat/sys/time.h index 76428c19..1f214152 100644 --- a/include/compat/sys/time.h +++ b/include/compat/sys/time.h @@ -8,6 +8,15 @@ #ifdef _MSC_VER #include + +#define timeval libressl_timeval +#define gettimeofday libressl_gettimeofday + +struct timeval { + long long tv_sec; + long tv_usec; +}; + int gettimeofday(struct timeval *tp, void *tzp); #else #include_next