Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/win32/sys_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <time.h>

/* Simple gettimeofday implementation without converting Windows time to Linux time */
/* Simple gettimeofday implementation */
int32_t gettimeofday(struct timeval *tv, struct timezone *tz) {
FILETIME ftime;
ULARGE_INTEGER ulint;
Expand All @@ -17,8 +17,10 @@ int32_t gettimeofday(struct timeval *tv, struct timezone *tz) {
ulint.LowPart = ftime.dwLowDateTime;
ulint.HighPart = ftime.dwHighDateTime;

tv->tv_sec = (int32_t) (ulint.QuadPart / 10000000L);
tv->tv_usec = (int32_t) (ulint.QuadPart % 10000000L);
ulint.QuadPart -= 116444736000000000LL; // shift base to unix epoch
ulint.QuadPart /= 10LL; // 100ns ticks to microseconds
tv->tv_sec = (int32_t) (ulint.QuadPart / 1000000LL);
tv->tv_usec = (int32_t) (ulint.QuadPart % 1000000LL);
}

if(NULL != tz) {
Expand Down
Loading