summaryrefslogtreecommitdiff
path: root/Source/WTF/wtf/CurrentTime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WTF/wtf/CurrentTime.cpp')
-rw-r--r--Source/WTF/wtf/CurrentTime.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/Source/WTF/wtf/CurrentTime.cpp b/Source/WTF/wtf/CurrentTime.cpp
index 8774314fe..90dce34a7 100644
--- a/Source/WTF/wtf/CurrentTime.cpp
+++ b/Source/WTF/wtf/CurrentTime.cpp
@@ -91,6 +91,35 @@ static double lowResUTCTime()
#if USE(QUERY_PERFORMANCE_COUNTER)
+#if defined(_WIN32) && (defined(__x86_64__) || defined(_AMD64_)) && _WIN32_WINNT < 0x0600
+/* GetTickCount64() is not available on XP. */
+ULONGLONG GetTickCount64 ()
+{
+ static ULONGLONG (CALLBACK *DynGetTickCount64)() = (ULONGLONG (*)(void))-1;
+ static DWORD last_ticks = 0;
+ static DWORD n_overflow = 0;
+ DWORD ticks = 0;
+ HINSTANCE hKernel32;
+
+ if (DynGetTickCount64 == (void*)-1)
+ {
+ hKernel32 = GetModuleHandleW(L"KERNEL32");
+ DynGetTickCount64 = *(ULONGLONG (*)(void))(GetProcAddress(hKernel32,
+ "GetTickCount64"));
+ }
+ if (DynGetTickCount64 != (void*) NULL)
+ {
+ return DynGetTickCount64();
+ }
+
+ ticks = GetTickCount();
+ if (ticks < last_ticks)
+ n_overflow++;
+ last_ticks = ticks;
+ return ((ULONGLONG)n_overflow << 32LL) + (ULONGLONG)GetTickCount();
+}
+#endif
+
static LARGE_INTEGER qpcFrequency;
static bool syncedTime;