mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
use GetSystemTimeAsFileTime with previous gettimeofday setup
This commit is contained in:
parent
ea8f0df17d
commit
00a826330e
2 changed files with 11 additions and 10 deletions
|
@ -38,21 +38,21 @@
|
|||
/** Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
|
||||
#define _W32_FT_OFFSET (116444736000000000ULL)
|
||||
|
||||
int __cdecl gettimeofday(struct timeval *__restrict__ tp,
|
||||
void *__restrict__ tzp __attribute__((unused))) {
|
||||
int gettimeofday(timeval* p_tv, timezone* p_tz) {
|
||||
|
||||
union {
|
||||
unsigned long long ns100; /**time since 1 Jan 1601 in 100ns units */
|
||||
FILETIME ft;
|
||||
} _now;
|
||||
|
||||
if (tp) {
|
||||
if (p_tv) {
|
||||
GetSystemTimeAsFileTime (&_now.ft);
|
||||
tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
|
||||
tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
|
||||
p_tv->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
|
||||
p_tv->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
|
||||
}
|
||||
|
||||
/** Always return 0 as per Open Group Base Specifications Issue 6.
|
||||
Do not set errno on error. */
|
||||
Do not set errno on error. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,12 @@
|
|||
|
||||
#include <winsock2.h>
|
||||
|
||||
extern "C" {
|
||||
struct timezone {
|
||||
int tz_minuteswest; /* minutes west of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
|
||||
int __cdecl gettimeofday(struct timeval *__restrict__, void *__restrict__);
|
||||
|
||||
}
|
||||
int gettimeofday(struct timeval* p_tv, struct timezone* p_tz);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue