diff options
| author | Theo Buehler <tb@openbsd.org> | 2024-08-02 21:54:08 +0200 |
|---|---|---|
| committer | Brent Cook <busterb@gmail.com> | 2024-10-06 18:56:01 -0500 |
| commit | 3467d6f282146d6e84d5d840d532fa6ec4536d64 (patch) | |
| tree | 63ff681422e02f5b289ab8453e04994b3f4d3a1d | |
| parent | 9a399d26a05396d9cfe1d1f6232e81f37c2acf21 (diff) | |
| download | portable-3467d6f282146d6e84d5d840d532fa6ec4536d64.tar.gz portable-3467d6f282146d6e84d5d840d532fa6ec4536d64.tar.bz2 portable-3467d6f282146d6e84d5d840d532fa6ec4536d64.zip | |
Attempt to fix 2038 problem with MSVC
| -rw-r--r-- | crypto/compat/posix_win.c | 4 | ||||
| -rw-r--r-- | include/compat/sys/time.h | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index bb3e653..bed8c84 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c | |||
| @@ -9,6 +9,8 @@ | |||
| 9 | 9 | ||
| 10 | #define NO_REDEF_POSIX_FUNCTIONS | 10 | #define NO_REDEF_POSIX_FUNCTIONS |
| 11 | 11 | ||
| 12 | #include <sys/time.h> | ||
| 13 | |||
| 12 | #include <ws2tcpip.h> | 14 | #include <ws2tcpip.h> |
| 13 | #include <windows.h> | 15 | #include <windows.h> |
| 14 | 16 | ||
| @@ -306,7 +308,7 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp) | |||
| 306 | time = ((uint64_t)file_time.dwLowDateTime); | 308 | time = ((uint64_t)file_time.dwLowDateTime); |
| 307 | time += ((uint64_t)file_time.dwHighDateTime) << 32; | 309 | time += ((uint64_t)file_time.dwHighDateTime) << 32; |
| 308 | 310 | ||
| 309 | tp->tv_sec = (long)((time - EPOCH) / 10000000L); | 311 | tp->tv_sec = (long long)((time - EPOCH) / 10000000L); |
| 310 | tp->tv_usec = (long)(system_time.wMilliseconds * 1000); | 312 | tp->tv_usec = (long)(system_time.wMilliseconds * 1000); |
| 311 | return 0; | 313 | return 0; |
| 312 | } | 314 | } |
diff --git a/include/compat/sys/time.h b/include/compat/sys/time.h index 76428c1..2448969 100644 --- a/include/compat/sys/time.h +++ b/include/compat/sys/time.h | |||
| @@ -8,6 +8,15 @@ | |||
| 8 | 8 | ||
| 9 | #ifdef _MSC_VER | 9 | #ifdef _MSC_VER |
| 10 | #include <winsock2.h> | 10 | #include <winsock2.h> |
| 11 | |||
| 12 | #define timeval libressl_timeval | ||
| 13 | #define gettimeofday libressl_gettimeofday | ||
| 14 | |||
| 15 | struct timeval { | ||
| 16 | long long tv_sec; | ||
| 17 | long tv_usec; | ||
| 18 | }; | ||
| 19 | |||
| 11 | int gettimeofday(struct timeval *tp, void *tzp); | 20 | int gettimeofday(struct timeval *tp, void *tzp); |
| 12 | #else | 21 | #else |
| 13 | #include_next <sys/time.h> | 22 | #include_next <sys/time.h> |
