[libcxx-commits] [PATCH] D104987: Use GetSystemTimePreciseAsFileTime() if available
Sizhe Zhao via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jun 27 00:21:53 PDT 2021
Prince213 updated this revision to Diff 354731.
Prince213 added a comment.
Fix format.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104987/new/
https://reviews.llvm.org/D104987
Files:
libcxx/src/chrono.cpp
Index: libcxx/src/chrono.cpp
===================================================================
--- libcxx/src/chrono.cpp
+++ libcxx/src/chrono.cpp
@@ -74,11 +74,17 @@
static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600};
FILETIME ft;
-#if _WIN32_WINNT >= _WIN32_WINNT_WIN8 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
- GetSystemTimePreciseAsFileTime(&ft);
-#else
- GetSystemTimeAsFileTime(&ft);
-#endif
+ typedef void(WINAPI * GetSysTime_t)(LPFILETIME);
+ static GetSysTime_t getSysTime_p;
+
+ GetSysTime_t getSysTime_f = getSysTime_p;
+ if (nullptr == getSysTime_f) {
+ getSysTime_f = (GetSysTime_t)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetSystemTimePreciseAsFileTime");
+ if (nullptr == getSysTime_f)
+ getSysTime_f = GetSystemTimeAsFileTime;
+ getSysTime_p = getSysTime_f;
+ }
+ getSysTime_f(&ft);
filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
static_cast<__int64>(ft.dwLowDateTime)};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104987.354731.patch
Type: text/x-patch
Size: 1010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210627/37b76b92/attachment.bin>
More information about the libcxx-commits
mailing list