Fix for Y2038 gettimeofday for Win32 builds (#738)

* Fix for Y2038 gettimeofday for Win32 builds

* fixing spaces

* Fixing also the builtin gettimeofday
This commit is contained in:
LainOTN2 2025-03-26 19:50:34 +01:00 committed by GitHub
parent ae72d833fd
commit 31f8d13ab6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -1,8 +1,16 @@
#pragma once
#include <sys\utime.h>
#define utimbuf _utimbuf
#define utimes w32_utimes
#define timeval w32_timeval
struct timeval
{
long long tv_sec;
long tv_usec;
};
int usleep(unsigned int);
int gettimeofday(struct timeval *, void *);
int nanosleep(const struct timespec *, struct timespec *);

View File

@ -207,7 +207,7 @@ gettimeofday(struct timeval *tv, void *tz)
us = (timehelper.ns - EPOCH_DELTA) / 10;
/* Stuff result into the timeval */
tv->tv_sec = (long)(us / USEC_IN_SEC);
tv->tv_sec = (long long)(us / USEC_IN_SEC);
tv->tv_usec = (long)(us % USEC_IN_SEC);
return 0;