Changeset 70335 in vbox
- Timestamp:
- Dec 24, 2017 2:37:32 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119935
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/nt/time-r0drv-nt.cpp
r69111 r70335 35 35 36 36 37 /* 38 * The KeQueryTickCount macro isn't compatible with NT 3.1, use the 39 * exported KPI instead. 40 */ 41 #ifdef RT_ARCH_X86 42 # undef KeQueryTickCount 43 extern "C" NTKERNELAPI void NTAPI KeQueryTickCount(PLARGE_INTEGER); 44 #endif 45 46 37 47 DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void) 38 48 { … … 57 67 InterruptTime.QuadPart = g_pfnrtKeQueryInterruptTimePrecise(&QpcTsIgnored); 58 68 } 59 # ifdef RT_ARCH_AMD64 60 else 61 InterruptTime.QuadPart = KeQueryInterruptTime(); /* macro */ 62 # else 63 else if (g_pfnrtKeQueryInterruptTime) 69 # ifdef RT_ARCH_X86 70 else if (g_pfnrtKeQueryInterruptTime) /* W2K+ */ 64 71 InterruptTime.QuadPart = g_pfnrtKeQueryInterruptTime(); 65 else 72 else if (g_uRtNtVersion >= RTNT_MAKE_VERSION(3, 50)) 66 73 { 67 /* NT 4 (no API) and pre-init fallback. */74 /* NT 3.50 and later, also pre-init: Use the user shared data. */ 68 75 do 69 76 { 70 77 InterruptTime.HighPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.High1Time; 71 InterruptTime.LowPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.LowPart;78 InterruptTime.LowPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.LowPart; 72 79 } while (((KUSER_SHARED_DATA volatile *)SharedUserData)->InterruptTime.High2Time != InterruptTime.HighPart); 73 80 } 81 else 82 { 83 /* 84 * There is no KUSER_SHARED_DATA structure on NT 3.1, so we have no choice 85 * but to use the tick count. We must also avoid the KeQueryTickCount macro 86 * in the WDK, since NT 3.1 does have the KeTickCount data export either (see above). 87 */ 88 static ULONG volatile s_uTimeIncrement = 0; 89 ULONG uTimeIncrement = s_uTimeIncrement; 90 if (!uTimeIncrement) 91 { 92 uTimeIncrement = KeQueryTimeIncrement(); 93 Assert(uTimeIncrement != 0); 94 Assert(uTimeIncrement * 100 / 100 == uTimeIncrement); 95 uTimeIncrement *= 100; 96 s_uTimeIncrement = uTimeIncrement; 97 } 98 99 KeQueryTickCount(&InterruptTime); 100 return (uint64_t)InterruptTime.QuadPart * uTimeIncrement; 101 } 102 # else 103 else 104 InterruptTime.QuadPart = KeQueryInterruptTime(); /* Macro on AMD64. */ 74 105 # endif 75 106 return (uint64_t)InterruptTime.QuadPart * 100; 76 107 #else 77 /* Tick Count (NT4 SP1 has these APIs, haven't got SP0 to check).*/108 /* Tick count. Works all the way back to NT 3.1 with #undef above. */ 78 109 LARGE_INTEGER Tick; 79 110 KeQueryTickCount(&Tick); … … 112 143 if (g_pfnrtKeQuerySystemTimePrecise) 113 144 g_pfnrtKeQuerySystemTimePrecise(&SystemTime); 114 #ifdef RT_ARCH_AMD64115 145 else 116 KeQuerySystemTime(&SystemTime); /* macro */ 117 #else 118 else if (g_pfnrtKeQuerySystemTime) 119 g_pfnrtKeQuerySystemTime(&SystemTime); 120 else 121 { 122 do 123 { 124 SystemTime.HighPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.High1Time; 125 SystemTime.LowPart = ((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.LowPart; 126 } while (((KUSER_SHARED_DATA volatile *)SharedUserData)->SystemTime.High2Time != SystemTime.HighPart); 127 } 128 #endif 146 KeQuerySystemTime(&SystemTime); /* Macro on AMD64, export on X86. */ 129 147 return RTTimeSpecSetNtTime(pTime, SystemTime.QuadPart); 130 148 }
Note:
See TracChangeset
for help on using the changeset viewer.