Changeset 62673 in vbox for trunk/src/VBox/ValidationKit/utils/nt
- Timestamp:
- Jul 29, 2016 11:04:35 AM (8 years ago)
- Location:
- trunk/src/VBox/ValidationKit/utils/nt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/nt/ntsetfreq.cpp
r62484 r62673 29 29 * Header Files * 30 30 *********************************************************************************************************************************/ 31 #define _WIN32_WINNT 0x0500 32 #include <Windows.h> 31 #include <iprt/nt/nt.h> 33 32 34 33 #include <iprt/initterm.h> … … 39 38 #include <iprt/thread.h> 40 39 #include <iprt/err.h> 41 42 RT_C_DECLS_BEGIN43 /* from sysinternals. */44 NTSYSAPI LONG NTAPI NtSetTimerResolution(IN ULONG DesiredResolution, IN BOOLEAN SetResolution, OUT PULONG CurrentResolution);45 NTSYSAPI LONG NTAPI NtQueryTimerResolution(OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, OUT PULONG CurrentResolution);46 RT_C_DECLS_END47 48 40 49 41 … … 109 101 * Query the current resolution. 110 102 */ 111 ULONG Cur = ~0;112 ULONG Min = ~0;113 ULONG Max = ~0;114 LONG Status;103 ULONG Cur = UINT32_MAX; 104 ULONG Min = UINT32_MAX; 105 ULONG Max = UINT32_MAX; 106 NTSTATUS rcNt = STATUS_SUCCESS; 115 107 if (fVerbose || !u32NewRes) 116 108 { 117 Status= NtQueryTimerResolution(&Min, &Max, &Cur);118 if ( Status >= 0)109 rcNt = NtQueryTimerResolution(&Min, &Max, &Cur); 110 if (NT_SUCCESS(rcNt)) 119 111 RTMsgInfo("cur: %u (%u.%02u Hz) min: %u (%u.%02u Hz) max: %u (%u.%02u Hz)\n", 120 112 Cur, 10000000 / Cur, (10000000 / (Cur * 100)) % 100, … … 122 114 Max, 10000000 / Max, (10000000 / (Max * 100)) % 100); 123 115 else 124 RTMsgError("NTQueryTimerResolution failed with status %#x\n", Status);116 RTMsgError("NTQueryTimerResolution failed with status %#x\n", rcNt); 125 117 } 126 118 127 119 if (u32NewRes) 128 120 { 129 Status= NtSetTimerResolution(u32NewRes, TRUE, &Cur);130 if ( Status < 0)131 RTMsgError("NTSetTimerResolution(%RU32,,) failed with status %#x\n", u32NewRes, Status);121 rcNt = NtSetTimerResolution(u32NewRes, TRUE, &Cur); 122 if (!NT_SUCCESS(rcNt)) 123 RTMsgError("NTSetTimerResolution(%RU32,,) failed with status %#x\n", u32NewRes, rcNt); 132 124 else if (fVerbose) 133 125 { 134 Cur = Min = Max = ~0;135 Status= NtQueryTimerResolution(&Min, &Max, &Cur);136 if ( Status >= 0)126 Cur = Min = Max = UINT32_MAX; 127 rcNt = NtQueryTimerResolution(&Min, &Max, &Cur); 128 if (NT_SUCCESS(rcNt)) 137 129 RTMsgInfo("new: %u (%u.%02u Hz) requested %RU32 (%u.%02u Hz)\n", 138 130 Cur, 10000000 / Cur, (10000000 / (Cur * 100)) % 100, 139 131 u32NewRes, 10000000 / u32NewRes, (10000000 / (u32NewRes * 100)) % 100); 140 132 else 141 RTMsgError("NTSetTimerResolution succeeded but the NTQueryTimerResolution call failed with status %#x (ignored)\n", Status); 142 Status = 0; 133 RTMsgError("NTSetTimerResolution succeeded but the NTQueryTimerResolution call failed with status %#x (ignored)\n", 134 rcNt); 135 rcNt = STATUS_SUCCESS; 143 136 } 144 137 } 145 138 146 if (u32NewRes && Status >= 0)139 if (u32NewRes && NT_SUCCESS(rcNt)) 147 140 { 148 141 if (cSecsSleep == UINT32_MAX) … … 154 147 } 155 148 156 return Status >= 0? 0 : 1;149 return NT_SUCCESS(rcNt) ? 0 : 1; 157 150 } 158 151 -
trunk/src/VBox/ValidationKit/utils/nt/nttimesources.cpp
r62484 r62673 29 29 * Header Files * 30 30 *********************************************************************************************************************************/ 31 #include < Windows.h>31 #include <iprt/win/windows.h> 32 32 33 33 #include <iprt/asm.h> … … 84 84 int main(int argc, char **argv) 85 85 { 86 RT_NOREF1(argv); 87 86 88 /* 87 89 * Init, create a test instance and "parse" arguments.
Note:
See TracChangeset
for help on using the changeset viewer.