From e9d7606869bd17f22bb7430481a661bab41194a2 Mon Sep 17 00:00:00 2001 From: Kartik Naik Date: Fri, 21 Aug 2026 12:09:04 +0530 Subject: use winsock's struct timeval in the msvc sys/time.h shim --- crypto/compat/posix_win.c | 2 +- include/compat/sys/time.h | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index 60b2896..14b79f5 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c @@ -303,7 +303,7 @@ int gettimeofday(struct timeval *tp, void *tzp) time = ((uint64_t)file_time.dwLowDateTime); time += ((uint64_t)file_time.dwHighDateTime) << 32; - tp->tv_sec = (long long)((time - EPOCH) / 10000000L); + tp->tv_sec = (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 2448969..0388333 100644 --- a/include/compat/sys/time.h +++ b/include/compat/sys/time.h @@ -7,16 +7,15 @@ #define LIBCRYPTOCOMPAT_SYS_TIME_H #ifdef _MSC_VER +/* + * Use the winsock struct timeval: it is what gives + * callers of DTLSv1_get_timeout() and the dgram BIO ctrls, so libssl + * must be built against the same layout. + */ #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 -- cgit v1.2.3-55-g6feb