24#define WIN32_NO_STATUS
32#define TICKSPERSEC 10000000
33#define TICKSPERMSEC 10000
34#define SECSPERDAY 86400
50 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
51 { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
56 return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0);
70 pRtlTimeToTimeFields( &litime, &tfresult);
74 "#%d expected: %d-%d-%d %d:%d:%d got: %d-%d-%d %d:%d:%d\n", ++
i,
80 pRtlTimeFieldsToTime( &tfresult, &liresult);
81 ok( liresult.
QuadPart == litime.
QuadPart,
" TimeFieldsToTime failed on %d-%d-%d %d:%d:%d. Error is %d ticks\n",
87 pRtlTimeToTimeFields( &litime, &tfresult);
90 tfresult.
Day == 1 && tfresult.
Hour == 0 &&
92 "#%d expected: %d-%d-%d %d:%d:%d got: %d-%d-%d %d:%d:%d\n", ++
i,
98 pRtlTimeFieldsToTime( &tfresult, &liresult);
99 ok( liresult.
QuadPart == litime.
QuadPart,
" TimeFieldsToTime failed on %d-%d-%d %d:%d:%d. Error is %d ticks\n",
124 status = pNtQueryPerformanceCounter(&
counter, (
void *)0xdeadbee0);
135#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arm64ec__)
137struct hypervisor_shared_data
148 m = (ah * bl) + (bh * al) + ((al * bl) >> 32);
149 return (ah * bh) + (
m >> 32);
152static void test_RtlQueryPerformanceCounter(
void)
154 struct hypervisor_shared_data *hsd;
162 if (!pRtlQueryPerformanceCounter || !pRtlQueryPerformanceFrequency)
164 win_skip(
"RtlQueryPerformanceCounter/Frequency not available, skipping tests\n" );
184 ok(
len ==
sizeof(
void *),
"unexpected SystemHypervisorSharedPageInformation length %lu\n",
len );
185 ok( !!hsd,
"unexpected SystemHypervisorSharedPageInformation address %p\n", hsd );
188 ret = pRtlQueryPerformanceCounter( &
counter );
190 ok(
ret,
"RtlQueryPerformanceCounter failed\n" );
192 tsc0 = multiply_tsc(tsc0, hsd->QpcMultiplier) + hsd->QpcBias + usd->
QpcBias;
193 tsc1 = multiply_tsc(tsc1, hsd->QpcMultiplier) + hsd->QpcBias + usd->
QpcBias;
195 ok( tsc0 <=
counter.QuadPart,
"rdtscp %I64d and RtlQueryPerformanceCounter %I64d are out of order\n", tsc0,
counter.QuadPart );
196 ok(
counter.QuadPart <= tsc1,
"RtlQueryPerformanceCounter %I64d and rdtscp %I64d are out of order\n",
counter.QuadPart, tsc1 );
203 ret = pRtlQueryPerformanceCounter( &
counter );
205 ok(
ret,
"RtlQueryPerformanceCounter failed\n" );
212 ok( tsc0 <=
counter.QuadPart,
"rdtscp %I64d and RtlQueryPerformanceCounter %I64d are out of order\n", tsc0,
counter.QuadPart );
213 ok(
counter.QuadPart <= tsc1,
"RtlQueryPerformanceCounter %I64d and rdtscp %I64d are out of order\n",
counter.QuadPart, tsc1 );
217 ok(
ret,
"RtlQueryPerformanceFrequency failed\n" );
219 "RtlQueryPerformanceFrequency returned %I64d, expected USD QpcFrequency %I64d\n",
224#define TIMER_LEEWAY 10
225#define CHECK_CURRENT_TIMER(expected) \
227 ok(status == STATUS_SUCCESS, "NtSetTimerResolution failed %lx\n", status); \
228 ok(cur2 == (expected) || broken(abs((int)((expected) - cur2)) <= TIMER_LEEWAY) ||
broken(GetNTVersion() < _WIN32_WINNT_WIN7), "expected new timer resolution %lu, got %lu\n", (expected), cur2); \
230 min2 = min + 20000; \
233 status = NtQueryTimerResolution(&min2, &max2, &cur2); \
234 ok(status == STATUS_SUCCESS, "NtQueryTimerResolution() failed %lx\n", status); \
235 ok(min2 == min, "NtQueryTimerResolution() expected min=%lu, got %lu\n", min, min2); \
236 ok(max2 == max, "NtQueryTimerResolution() expected max=%lu, got %lu\n", max, max2); \
237 ok(cur2 == set, "NtQueryTimerResolution() expected timer resolution %lu, got %lu\n", set, cur2); \
260 "unexpected minimum timer resolution %lu\n",
min);
261 ok(0 <
max,
"invalid maximum timer resolution, should be 0 < %lu\n",
max);
277 ok(min2 ==
min,
"NtQueryTimerResolution() expected min=%lu, got %lu\n",
min, min2);
278 ok(max2 ==
max,
"NtQueryTimerResolution() expected max=%lu, got %lu\n",
max, max2);
279 ok(cur2 ==
cur,
"NtQueryTimerResolution() expected timer resolution %lu, got %lu\n",
cur, cur2);
286 ok(cur2 ==
cur,
"expected requested timer resolution %lu, got %lu\n",
cur, cur2);
298 ok(cur2 ==
cur,
"expected requested timer resolution %lu, got %lu\n",
min, cur2);
303 ok(cur2 ==
cur,
"expected requested timer resolution %lu, got %lu\n",
cur, cur2);
323 trace(
"timer resolution: %lu(max) <= %lu(cur) <= %lu(prev) <= %lu(min)\n",
max, cur2,
cur,
min);
333 ok(cur2 ==
cur,
"expected requested timer resolution %lu, got %lu\n",
set, cur2);
344 if (!pRtlQueryTimeZoneInformation || !pRtlQueryDynamicTimeZoneInformation)
346 win_skip(
"Time zone name tests require Vista or later\n");
350 memset(&tzinfo, 0xcc,
sizeof(tzinfo));
351 status = pRtlQueryDynamicTimeZoneInformation(&tzinfo);
353 "RtlQueryDynamicTimeZoneInformation failed, got %08lx\n",
status);
356 "standard time zone name isn't an indirect string, got %s\n",
360 "daylight time zone name isn't an indirect string, got %s\n",
363 memset(&tzinfo2, 0xcc,
sizeof(tzinfo2));
366 ok(
len ==
sizeof(tzinfo2),
"wrong len %lu\n",
len );
367 ok( !
memcmp( &tzinfo, &tzinfo2,
sizeof(tzinfo2) ),
"tz data is different\n" );
369 memset(&tzinfo, 0xcc,
sizeof(tzinfo));
372 "RtlQueryTimeZoneInformation failed, got %08lx\n",
status);
375 "standard time zone name isn't an indirect string, got %s\n",
379 "daylight time zone name isn't an indirect string, got %s\n",
382 memset(&tzinfo, 0xcc,
sizeof(tzinfo));
385 "RtlQueryTimeZoneInformation failed, got %08lx\n",
status);
388 "standard time zone name isn't an indirect string, got %s\n",
392 "daylight time zone name isn't an indirect string, got %s\n",
395 memset(&tzinfo2, 0xcc,
sizeof(tzinfo2));
408 high =
time->High1Time;
411 while (high !=
time->High2Time);
412 return high << 32 | low;
432 }
while(t3 < t1 &&
i++ < 1);
434 ok(t1 <= t2,
"USD TickCount / GetTickCount are out of order: %s %s\n",
436 ok(t2 <= t3,
"USD TickCount / GetTickCount are out of order: %s %s\n",
448 }
while(t3 < t1 &&
i++ < 1);
452 ok(t1 <= t2,
"USD SystemTime / NtQuerySystemTime are out of order %s %s\n",
454 ok(t2 <= t3,
"USD SystemTime / NtQuerySystemTime are out of order %s %s\n",
457 if (!pRtlQueryUnbiasedInterruptTime)
458 win_skip(
"skipping RtlQueryUnbiasedInterruptTime tests\n");
464 pRtlQueryUnbiasedInterruptTime(&t1);
466 pRtlQueryUnbiasedInterruptTime(&t3);
467 }
while(t3 < t1 &&
i++ < 1);
469 ok(t1 <= t2,
"USD InterruptTime / RtlQueryUnbiasedInterruptTime are out of order %s %s\n",
471 ok(t2 <= t3,
"USD InterruptTime / RtlQueryUnbiasedInterruptTime are out of order %s %s\n",
477 ok(!
status,
"failed to query time of day, status %#lx\n",
status);
487 pNtQueryPerformanceCounter = (
void *)
GetProcAddress(
mod,
"NtQueryPerformanceCounter");
488 pNtQuerySystemInformation = (
void *)
GetProcAddress(
mod,
"NtQuerySystemInformation");
489 pRtlQueryTimeZoneInformation =
491 pRtlQueryDynamicTimeZoneInformation =
493 pRtlQueryUnbiasedInterruptTime = (
void *)
GetProcAddress(
mod,
"RtlQueryUnbiasedInterruptTime");
494 pRtlQueryPerformanceCounter = (
void *)
GetProcAddress(
mod,
"RtlQueryPerformanceCounter");
495 pRtlQueryPerformanceFrequency = (
void *)
GetProcAddress(
mod,
"RtlQueryPerformanceFrequency");
497 if (pRtlTimeToTimeFields && pRtlTimeFieldsToTime)
500 win_skip(
"Required time conversion functions are not available\n");
504#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arm64ec__)
505 test_RtlQueryPerformanceCounter();
std::map< E_MODULE, HMODULE > mod
COMPILER_DEPENDENT_UINT64 UINT64
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
#define GetProcAddress(x, y)
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
static const struct _KUSER_SHARED_DATA * user_shared_data
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
static const int MonthLengths[2][12]
@ SystemCurrentTimeZoneInformation
@ SystemTimeOfDayInformation
enum _SYSTEM_INFORMATION_CLASS SYSTEM_INFORMATION_CLASS
#define STATUS_ACCESS_VIOLATION
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
PPC_QUAL unsigned long long __rdtsc(void)
#define todo_wine_if(is_todo)
static void test_NtQueryPerformanceCounter(void)
static void test_user_shared_data_time(void)
static void test_pRtlTimeToTimeFields(void)
static PLARGE_INTEGER Time
static LARGE_INTEGER * frequency
static TIME_FIELDS tftest
static ULONGLONG read_ksystem_time(volatile KSYSTEM_TIME *time)
static void test_TimerResolution(void)
#define CHECK_CURRENT_TIMER(expected)
static void ULONG ULONG * ret_size
static PTIME_FIELDS TimeFields
static void test_RtlQueryTimeZoneInformation(void)
@ SystemHypervisorSharedPageInformation
@ SystemDynamicTimeZoneInformation
NTSTATUS NTAPI NtQueryTimerResolution(OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, OUT PULONG ActualResolution)
NTSTATUS NTAPI NtSetTimerResolution(IN ULONG DesiredResolution, IN BOOLEAN SetResolution, OUT PULONG CurrentResolution)
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
#define STATUS_TIMER_RESOLUTION_NOT_SET
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
volatile ULONGLONG QpcBias
UCHAR volatile QpcBypassEnabled
#define SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_RDTSCP
#define SHARED_GLOBAL_FLAGS_QPC_BYPASS_ENABLED
#define SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_HV_PAGE