Changeset 6267 in vbox
- Timestamp:
- Jan 7, 2008 10:00:46 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/time-win.cpp
r5999 r6267 30 30 *******************************************************************************/ 31 31 #define LOG_GROUP RTLOGGROUP_TIME 32 //#define USE_TICK_COUNT 33 //#define USE_PERFORMANCE_COUNTER 34 #define USE_FILE_TIME 35 //#define USE_INTERRUPT_TIME 36 #ifndef USE_INTERRUPT_TIME 37 # include <Windows.h> 38 #else 39 # define _X86_ 40 extern "C" { 41 # include <ntddk.h> 42 } 43 # undef PAGE_SIZE 44 # undef PAGE_SHIFT 45 #endif 32 #include <Windows.h> 46 33 47 34 #include <iprt/time.h> … … 50 37 #include "internal/time.h" 51 38 39 #define USE_TICK_COUNT 40 //#define USE_PERFORMANCE_COUNTER 41 #if 0//defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64) 42 # define USE_INTERRUPT_TIME 43 #else 44 //# define USE_FILE_TIME 45 #endif 46 47 48 #ifdef USE_INTERRUPT_TIME 49 50 typedef struct _MY_KSYSTEM_TIME 51 { 52 ULONG LowPart; 53 LONG High1Time; 54 LONG High2Time; 55 } MY_KSYSTEM_TIME; 56 57 typedef struct _MY_KUSER_SHARED_DATA 58 { 59 ULONG TickCountLowDeprecated; 60 ULONG TickCountMultiplier; 61 volatile MY_KSYSTEM_TIME InterruptTime; 62 /* The rest is not relevant. */ 63 } MY_KUSER_SHARED_DATA, *PMY_KUSER_SHARED_DATA; 64 65 #endif /* USE_INTERRUPT_TIME */ 66 52 67 53 68 DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void) 54 69 { 55 70 #if defined USE_TICK_COUNT 71 /* 72 * This would work if it didn't flip over every 49 (or so) days. 73 */ 56 74 return (uint64_t)GetTickCount() * (uint64_t)1000000; 57 75 58 76 #elif defined USE_PERFORMANCE_COUNTER 77 /* 78 * Slow and no derived from InterruptTime. 79 */ 59 80 static LARGE_INTEGER llFreq; 60 81 static unsigned uMult; … … 64 85 return (uint64_t)GetTickCount() * (uint64_t)1000000; 65 86 llFreq.QuadPart /= 1000; 66 uMult = 1000000; /* no math geni ous, but this seemed to help avoiding floating point. */87 uMult = 1000000; /* no math genius, but this seemed to help avoiding floating point. */ 67 88 } 68 89 … … 74 95 75 96 #elif defined USE_FILE_TIME 97 /* 98 * This is SystemTime not InterruptTime. 99 */ 76 100 uint64_t u64; /* manual say larger integer, should be safe to assume it's the same. */ 77 101 GetSystemTimeAsFileTime((LPFILETIME)&u64); … … 79 103 80 104 #elif defined USE_INTERRUPT_TIME 81 82 /* HACK! HACK! HACK! HACK! HACK! HACK! */ 83 /* HACK! HACK! HACK! HACK! HACK! HACK! */ 84 /* HACK! HACK! HACK! HACK! HACK! HACK! */ 85 # error "don't use this in production" 86 87 static const KUSER_SHARED_DATA *s_pUserSharedData = NULL; 105 /* 106 * This is exactly what we want, but we have to obtain it by non-official 107 * means. 108 */ 109 static MY_KUSER_SHARED_DATA *s_pUserSharedData = NULL; 88 110 if (!s_pUserSharedData) 89 111 { 90 /** @todo clever detection algorithm. 91 * The com debugger class exports this too, windbg knows it too... */ 92 s_pUserSharedData = (const KUSER_SHARED_DATA *)0x7ffe0000; 112 /** @todo find official way of getting this or some more clever 113 * detection algorithm if necessary. The com debugger class 114 * exports this too, windbg knows it too... */ 115 s_pUserSharedData = (MY_ KUSER_SHARED_DATA *)(uintptr_t)0x7ffe0000; 93 116 } 94 117 … … 98 121 { 99 122 Time.HighPart = s_pUserSharedData->InterruptTime.High1Time; 100 Time.LowPart = s_pUserSharedData->InterruptTime.LowPart;123 Time.LowPart = s_pUserSharedData->InterruptTime.LowPart; 101 124 } while (s_pUserSharedData->InterruptTime.High2Time != Time.HighPart); 102 125
Note:
See TracChangeset
for help on using the changeset viewer.