Changeset 70405 in vbox for trunk/src/VBox/Runtime/r3/win
- Timestamp:
- Jan 1, 2018 5:45:14 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/time-win.cpp
r70402 r70405 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 30 30 *********************************************************************************************************************************/ 31 31 #define LOG_GROUP RTLOGGROUP_TIME 32 #include <iprt/ win/windows.h>32 #include <iprt/nt/nt-and-windows.h> 33 33 34 34 #include <iprt/time.h> … … 53 53 //#endif 54 54 55 56 #ifdef USE_INTERRUPT_TIME57 58 typedef struct _MY_KSYSTEM_TIME59 {60 ULONG LowPart;61 LONG High1Time;62 LONG High2Time;63 } MY_KSYSTEM_TIME;64 65 typedef struct _MY_KUSER_SHARED_DATA66 {67 ULONG TickCountLowDeprecated;68 ULONG TickCountMultiplier;69 volatile MY_KSYSTEM_TIME InterruptTime;70 /* The rest is not relevant. */71 } MY_KUSER_SHARED_DATA, *PMY_KUSER_SHARED_DATA;72 73 #endif /* USE_INTERRUPT_TIME */74 55 75 56 … … 112 93 /* 113 94 * Use interrupt time if we can (not possible on NT 3.1). 95 * Note! We cannot entirely depend on g_enmWinVer here as we're likely to 96 * get called before IPRT is initialized. Ditto g_hModNtDll. 114 97 */ 115 /** @todo use RtlGetInterruptTimePrecise if available (W10+). */ 116 117 static int volatile g_fCanUseUserSharedData = -1; 118 int fCanUseUserSharedData = g_fCanUseUserSharedData; 119 if (fCanUseUserSharedData != -1) 98 static PFNRTLGETINTERRUPTTIMEPRECISE s_pfnRtlGetInterruptTimePrecise = NULL; 99 static int volatile s_iCanUseUserSharedData = -1; 100 int iCanUseUserSharedData = s_iCanUseUserSharedData; 101 if (iCanUseUserSharedData != -1) 120 102 { /* likely */ } 121 103 else … … 123 105 /* We may be called before g_enmWinVer has been initialized. */ 124 106 if (g_enmWinVer != kRTWinOSType_UNKNOWN) 125 fCanUseUserSharedData = g_enmWinVer > kRTWinOSType_NT310;107 iCanUseUserSharedData = g_enmWinVer > kRTWinOSType_NT310; 126 108 else 127 109 { 128 110 DWORD dwVer = GetVersion(); 129 fCanUseUserSharedData = (dwVer & 0xff) != 3 || ((dwVer >> 8) & 0xff) >= 50;111 iCanUseUserSharedData = (dwVer & 0xff) != 3 || ((dwVer >> 8) & 0xff) >= 50; 130 112 } 131 g_fCanUseUserSharedData = fCanUseUserSharedData; 113 if (iCanUseUserSharedData != 0) 114 { 115 FARPROC pfn = GetProcAddress(g_hModNtDll ? g_hModNtDll : GetModuleHandleW(L"ntdll"), "RtlGetInterruptTimePrecise"); 116 if (pfn != NULL) 117 { 118 ASMAtomicWritePtr(&s_pfnRtlGetInterruptTimePrecise, pfn); 119 iCanUseUserSharedData = 42; 120 } 121 } 122 s_iCanUseUserSharedData = iCanUseUserSharedData; 132 123 } 133 124 134 if ( fCanUseUserSharedData != 0)125 if (iCanUseUserSharedData != 0) 135 126 { 136 PMY_KUSER_SHARED_DATA pUserSharedData = (PMY_KUSER_SHARED_DATA)(uintptr_t)0x7ffe0000;137 127 LARGE_INTEGER Time; 138 do128 if (iCanUseUserSharedData == 42) 139 129 { 140 Time.HighPart = pUserSharedData->InterruptTime.High1Time; 141 Time.LowPart = pUserSharedData->InterruptTime.LowPart; 142 } while (pUserSharedData->InterruptTime.High2Time != Time.HighPart); 130 uint64_t iIgnored; 131 Time.QuadPart = s_pfnRtlGetInterruptTimePrecise(&iIgnored); 132 } 133 else 134 { 135 PKUSER_SHARED_DATA pUserSharedData = (PKUSER_SHARED_DATA)MM_SHARED_USER_DATA_VA; 136 do 137 { 138 Time.HighPart = pUserSharedData->InterruptTime.High1Time; 139 Time.LowPart = pUserSharedData->InterruptTime.LowPart; 140 } while (pUserSharedData->InterruptTime.High2Time != Time.HighPart); 141 } 143 142 144 143 return (uint64_t)Time.QuadPart * 100;
Note:
See TracChangeset
for help on using the changeset viewer.