Skip to content

Commit 31f8d13

Browse files
authored
Fix for Y2038 gettimeofday for Win32 builds (#738)
* Fix for Y2038 gettimeofday for Win32 builds * fixing spaces * Fixing also the builtin gettimeofday
1 parent ae72d83 commit 31f8d13

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

contrib/win32/win32compat/inc/sys/time.h

+8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
#pragma once
12
#include <sys\utime.h>
23

34
#define utimbuf _utimbuf
45
#define utimes w32_utimes
56

7+
#define timeval w32_timeval
8+
struct timeval
9+
{
10+
long long tv_sec;
11+
long tv_usec;
12+
};
13+
614
int usleep(unsigned int);
715
int gettimeofday(struct timeval *, void *);
816
int nanosleep(const struct timespec *, struct timespec *);

contrib/win32/win32compat/misc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ gettimeofday(struct timeval *tv, void *tz)
207207
us = (timehelper.ns - EPOCH_DELTA) / 10;
208208

209209
/* Stuff result into the timeval */
210-
tv->tv_sec = (long)(us / USEC_IN_SEC);
210+
tv->tv_sec = (long long)(us / USEC_IN_SEC);
211211
tv->tv_usec = (long)(us % USEC_IN_SEC);
212212

213213
return 0;

0 commit comments

Comments
 (0)