kopia lustrzana https://github.com/stlink-org/stlink
Fix Win32 gettimeofday implementation
rodzic
5259daa4bf
commit
aaf3eaefc0
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
|
Ładowanie…
Reference in New Issue