|
|
@ -944,18 +944,27 @@ void cgtime(struct timeval *tv) |
|
|
|
#else |
|
|
|
#else |
|
|
|
/* Windows start time is since 1601 lol so convert it to unix epoch 1970. */ |
|
|
|
/* Windows start time is since 1601 lol so convert it to unix epoch 1970. */ |
|
|
|
#define EPOCHFILETIME (116444736000000000LL) |
|
|
|
#define EPOCHFILETIME (116444736000000000LL) |
|
|
|
void cgtime(struct timeval *tv) |
|
|
|
|
|
|
|
|
|
|
|
/* Return the system time as an lldiv_t in decimicroseconds. */ |
|
|
|
|
|
|
|
static void decius_time(lldiv_t *lidiv) |
|
|
|
{ |
|
|
|
{ |
|
|
|
FILETIME ft; |
|
|
|
FILETIME ft; |
|
|
|
LARGE_INTEGER li; |
|
|
|
LARGE_INTEGER li; |
|
|
|
lldiv_t lidiv; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetSystemTimeAsFileTime(&ft); |
|
|
|
GetSystemTimeAsFileTime(&ft); |
|
|
|
li.LowPart = ft.dwLowDateTime; |
|
|
|
li.LowPart = ft.dwLowDateTime; |
|
|
|
li.HighPart = ft.dwHighDateTime; |
|
|
|
li.HighPart = ft.dwHighDateTime; |
|
|
|
li.QuadPart -= EPOCHFILETIME; |
|
|
|
li.QuadPart -= EPOCHFILETIME; |
|
|
|
|
|
|
|
|
|
|
|
/* SystemTime is in decimicroseconds so divide by an unusual number */ |
|
|
|
/* SystemTime is in decimicroseconds so divide by an unusual number */ |
|
|
|
lidiv = lldiv(li.QuadPart, 10000000); |
|
|
|
*lidiv = lldiv(li.QuadPart, 10000000); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cgtime(struct timeval *tv) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
lldiv_t lidiv; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decius_time(&lidiv); |
|
|
|
tv->tv_sec = lidiv.quot; |
|
|
|
tv->tv_sec = lidiv.quot; |
|
|
|
tv->tv_usec = lidiv.rem / 10; |
|
|
|
tv->tv_usec = lidiv.rem / 10; |
|
|
|
} |
|
|
|
} |
|
|
|