File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 66
77#include <time.h>
88
9- /* Simple gettimeofday implementation without converting Windows time to Linux time */
9+ /* Simple gettimeofday implementation */
1010int32_t gettimeofday (struct timeval * tv , struct timezone * tz ) {
1111 FILETIME ftime ;
1212 ULARGE_INTEGER ulint ;
@@ -17,8 +17,10 @@ int32_t gettimeofday(struct timeval *tv, struct timezone *tz) {
1717 ulint .LowPart = ftime .dwLowDateTime ;
1818 ulint .HighPart = ftime .dwHighDateTime ;
1919
20- tv -> tv_sec = (int32_t ) (ulint .QuadPart / 10000000L );
21- tv -> tv_usec = (int32_t ) (ulint .QuadPart % 10000000L );
20+ ulint .QuadPart -= 116444736000000000LL ; // shift base to unix epoch
21+ ulint .QuadPart /= 10LL ; // 100ns ticks to microseconds
22+ tv -> tv_sec = (int32_t ) (ulint .QuadPart / 1000000LL );
23+ tv -> tv_usec = (int32_t ) (ulint .QuadPart % 1000000LL );
2224 }
2325
2426 if (NULL != tz ) {
You can’t perform that action at this time.
0 commit comments