Skip to content

Commit

Permalink
Attempt to fix 2038 problem with MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
botovq committed Aug 2, 2024
1 parent 58f8cd7 commit 4b11e1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crypto/compat/posix_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#define NO_REDEF_POSIX_FUNCTIONS

#include <sys/time.h>

#include <ws2tcpip.h>
#include <windows.h>

Expand Down Expand Up @@ -306,7 +308,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;
}
Expand Down
9 changes: 9 additions & 0 deletions include/compat/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@

#ifdef _MSC_VER
#include <winsock2.h>

#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 <sys/time.h>
Expand Down

0 comments on commit 4b11e1c

Please sign in to comment.