mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1004923 part 12 - Use GetSystemTimePreciseAsFileTime if available (Windows 8). r=njn
This commit is contained in:
parent
50f6afb5fc
commit
0f21f62265
@ -123,6 +123,8 @@ NowCalibrate()
|
||||
|
||||
static const unsigned DataLockSpinCount = 4096;
|
||||
|
||||
static void (WINAPI *pGetSystemTimePreciseAsFileTime)(LPFILETIME) = nullptr;
|
||||
|
||||
void
|
||||
PRMJ_NowInit()
|
||||
{
|
||||
@ -141,6 +143,12 @@ PRMJ_NowInit()
|
||||
#ifdef JS_THREADSAFE
|
||||
InitializeCriticalSectionAndSpinCount(&calibration.data_lock, DataLockSpinCount);
|
||||
#endif
|
||||
|
||||
// Windows 8 has a new API function we can use.
|
||||
if (HMODULE h = GetModuleHandle("kernel32.dll")) {
|
||||
pGetSystemTimePreciseAsFileTime =
|
||||
(void (WINAPI *)(LPFILETIME))GetProcAddress(h, "GetSystemTimePreciseAsFileTime");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
@ -166,6 +174,13 @@ PRMJ_NowShutdown()
|
||||
int64_t
|
||||
PRMJ_Now()
|
||||
{
|
||||
if (pGetSystemTimePreciseAsFileTime) {
|
||||
// Windows 8 has a new API function that does all the work.
|
||||
FILETIME ft;
|
||||
pGetSystemTimePreciseAsFileTime(&ft);
|
||||
return int64_t(FileTimeToUnixMicroseconds(ft));
|
||||
}
|
||||
|
||||
bool calibrated = false;
|
||||
bool needsCalibration = !calibration.calibrated;
|
||||
double cachedOffset = 0.0;
|
||||
|
Loading…
Reference in New Issue
Block a user