mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 23:34:13 +08:00
test: fix now_realtime() for Windows.
This commit is contained in:
parent
925064aa11
commit
99abf56c6c
@ -73,11 +73,20 @@ time from_ms(uint64_t ms) {
|
|||||||
|
|
||||||
time now_realtime() {
|
time now_realtime() {
|
||||||
#if defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS)
|
#if defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS)
|
||||||
|
static void(WINAPI * query_time)(LPFILETIME);
|
||||||
|
if (!query_time) {
|
||||||
|
query_time = (void(WINAPI *)(LPFILETIME))GetProcAddress(
|
||||||
|
GetModuleHandle(TEXT("kernel32.dll")),
|
||||||
|
"GetSystemTimePreciseAsFileTime");
|
||||||
|
if (!query_time)
|
||||||
|
query_time = GetSystemTimeAsFileTime;
|
||||||
|
}
|
||||||
|
|
||||||
FILETIME filetime;
|
FILETIME filetime;
|
||||||
GetSystemTimeAsFileTime(&filetime);
|
query_time(&filetime);
|
||||||
uint64_t ns =
|
uint64_t ns100 =
|
||||||
(uint64_t)filetime.dwHighDateTime << 32 | filetime.dwLowDateTime;
|
(uint64_t)filetime.dwHighDateTime << 32 | filetime.dwLowDateTime;
|
||||||
return from_ns(ns);
|
return from_ns((ns100 - UINT64_C(116444736000000000)) * 100u);
|
||||||
#else
|
#else
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
if (unlikely(clock_gettime(CLOCK_REALTIME, &ts)))
|
if (unlikely(clock_gettime(CLOCK_REALTIME, &ts)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user