Bug 1317259 - Prevent double init in mozilla::TimeStamp::Startup() on Windows. r?froydnj
MozReview-Commit-ID: JKfEFqo5qHj
--- a/mozglue/misc/TimeStamp_windows.cpp
+++ b/mozglue/misc/TimeStamp_windows.cpp
@@ -469,19 +469,27 @@ HasStableTSC()
}
__cpuid(regs, 0x80000007);
// if bit 8 is set than TSC will run at a constant rate
// in all ACPI P-state, C-states and T-states
return regs[3] & (1 << 8);
}
+static bool gInitialized = false;
+
MFBT_API void
TimeStamp::Startup()
{
+ if (gInitialized) {
+ return;
+ }
+
+ gInitialized = true;
+
// Decide which implementation to use for the high-performance timer.
HMODULE kernelDLL = GetModuleHandleW(L"kernel32.dll");
sGetTickCount64 = reinterpret_cast<GetTickCount64_t>(
GetProcAddress(kernelDLL, "GetTickCount64"));
if (!sGetTickCount64) {
// If the platform does not support the GetTickCount64 (Windows XP doesn't),
// then use our fallback implementation based on GetTickCount.