-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1074 from slyshykO/fix_msvc_gettimeofday
Fixed gettimeofday for msvc
- Loading branch information
Showing
2 changed files
with
23 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,33 @@ | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
#include "sys_time.h" | ||
|
||
#ifndef STLINK_HAVE_SYS_TIME_H | ||
|
||
#include <time.h> | ||
|
||
/* Simple gettimeofday implementation without converting Windows time to Linux time */ | ||
int gettimeofday(struct timeval *tv, struct timezone *tz) { | ||
FILETIME ftime; | ||
ULARGE_INTEGER ulint; | ||
static int tzflag = 0; | ||
|
||
if(NULL != tv) { | ||
GetSystemTimeAsFileTime(&ftime); | ||
ulint.LowPart = ftime.dwLowDateTime; | ||
ulint.HighPart = ftime.dwHighDateTime; | ||
|
||
GetSystemTimeAsFileTime(&ftime); | ||
ulint.LowPart = ftime.dwLowDateTime; | ||
ulint.HighPart = ftime.dwHighDateTime; | ||
tv->tv_sec = (long)(ulint.QuadPart / 10000000L); | ||
tv->tv_usec = (long)(ulint.QuadPart % 10000000L); | ||
} | ||
|
||
tv->tv_sec = (long)(ulint.QuadPart / 10000000L); | ||
tv->tv_usec = (long)(ulint.QuadPart % 10000000L); | ||
if(NULL != tz) { | ||
if (!tzflag) { | ||
_tzset(); | ||
tzflag++; | ||
} | ||
tz->tz_minuteswest = _timezone / 60; | ||
tz->tz_dsttime = _daylight; | ||
} | ||
|
||
return 0; | ||
(void)tz; | ||
} | ||
#endif //STLINK_HAVE_SYS_TIME_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters