ReactOS 0.4.17-dev-116-ga4b6fe9
time.c File Reference
#include <stdarg.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "ddk/wdm.h"
#include "intrin.h"
#include "wine/test.h"
Include dependency graph for time.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define TICKSPERSEC   10000000
 
#define TICKSPERMSEC   10000
 
#define SECSPERDAY   86400
 
#define TIMER_LEEWAY   10
 
#define CHECK_CURRENT_TIMER(expected)
 

Functions

static VOID (WINAPI *pRtlTimeToTimeFields)(const LARGE_INTEGER *liTime
 
static NTSTATUS (WINAPI *pNtQueryPerformanceCounter)(LARGE_INTEGER *counter
 
static BOOL (WINAPI *pRtlQueryUnbiasedInterruptTime)(ULONGLONG *time)
 
static BOOL IsLeapYear (int Year)
 
static void test_pRtlTimeToTimeFields (void)
 
static void test_NtQueryPerformanceCounter (void)
 
static void test_TimerResolution (void)
 
static void test_RtlQueryTimeZoneInformation (void)
 
static ULONGLONG read_ksystem_time (volatile KSYSTEM_TIME *time)
 
static void test_user_shared_data_time (void)
 
 START_TEST (time)
 

Variables

static PTIME_FIELDS TimeFields
 
static PLARGE_INTEGER Time
 
static LARGE_INTEGERfrequency
 
static voidinfo
 
static void ULONG size
 
static void ULONG ULONGret_size
 
static const int MonthLengths [2][12]
 
static TIME_FIELDS tftest = {1889,12,31,23,59,59,0,0}
 

Macro Definition Documentation

◆ CHECK_CURRENT_TIMER

#define CHECK_CURRENT_TIMER (   expected)
Value:
do { \
ok(status == STATUS_SUCCESS, "NtSetTimerResolution failed %lx\n", status); \
ok(cur2 == (expected) || broken(abs((int)((expected) - cur2)) <= TIMER_LEEWAY) || /* __REACTOS__ */ broken(GetNTVersion() < _WIN32_WINNT_WIN7), "expected new timer resolution %lu, got %lu\n", (expected), cur2); \
set = cur2; \
min2 = min + 20000; \
cur2 = min2 + 1; \
max2 = cur2 + 1; \
status = NtQueryTimerResolution(&min2, &max2, &cur2); \
ok(status == STATUS_SUCCESS, "NtQueryTimerResolution() failed %lx\n", status); \
ok(min2 == min, "NtQueryTimerResolution() expected min=%lu, got %lu\n", min, min2); \
ok(max2 == max, "NtQueryTimerResolution() expected max=%lu, got %lu\n", max, max2); \
ok(cur2 == set, "NtQueryTimerResolution() expected timer resolution %lu, got %lu\n", set, cur2); \
} while (0)
#define GetNTVersion()
Definition: apitest.h:17
#define broken(x)
Definition: atltest.h:178
Definition: _set.h:50
#define abs(i)
Definition: fconv.c:206
BOOL expected
Definition: store.c:2000
#define TIMER_LEEWAY
Definition: time.c:224
#define min(a, b)
Definition: monoChain.cc:55
NTSTATUS NTAPI NtQueryTimerResolution(OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, OUT PULONG ActualResolution)
Definition: time.c:627
#define _WIN32_WINNT_WIN7
Definition: sdkddkver.h:28
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ps.c:97
#define max(a, b)
Definition: svc.c:63

Definition at line 225 of file time.c.

◆ SECSPERDAY

#define SECSPERDAY   86400

Definition at line 34 of file time.c.

◆ TICKSPERMSEC

#define TICKSPERMSEC   10000

Definition at line 33 of file time.c.

◆ TICKSPERSEC

#define TICKSPERSEC   10000000

Definition at line 32 of file time.c.

◆ TIMER_LEEWAY

#define TIMER_LEEWAY   10

Definition at line 224 of file time.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 24 of file time.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pRtlQueryUnbiasedInterruptTime)
static

◆ IsLeapYear()

static BOOL IsLeapYear ( int  Year)
inlinestatic

Definition at line 54 of file time.c.

55{
56 return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0);
57}

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtQueryPerformanceCounter)
static

◆ read_ksystem_time()

static ULONGLONG read_ksystem_time ( volatile KSYSTEM_TIME time)
static

Definition at line 403 of file time.c.

404{
405 ULONGLONG high, low;
406 do
407 {
408 high = time->High1Time;
409 low = time->LowPart;
410 }
411 while (high != time->High2Time);
412 return high << 32 | low;
413}
__u16 time
Definition: mkdosfs.c:8
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by test_user_shared_data_time().

◆ START_TEST()

START_TEST ( time  )

Definition at line 482 of file time.c.

483{
484 HMODULE mod = GetModuleHandleA("ntdll.dll");
485 pRtlTimeToTimeFields = (void *)GetProcAddress(mod,"RtlTimeToTimeFields");
486 pRtlTimeFieldsToTime = (void *)GetProcAddress(mod,"RtlTimeFieldsToTime");
487 pNtQueryPerformanceCounter = (void *)GetProcAddress(mod, "NtQueryPerformanceCounter");
488 pNtQuerySystemInformation = (void *)GetProcAddress(mod, "NtQuerySystemInformation");
489 pRtlQueryTimeZoneInformation =
490 (void *)GetProcAddress(mod, "RtlQueryTimeZoneInformation");
491 pRtlQueryDynamicTimeZoneInformation =
492 (void *)GetProcAddress(mod, "RtlQueryDynamicTimeZoneInformation");
493 pRtlQueryUnbiasedInterruptTime = (void *)GetProcAddress(mod, "RtlQueryUnbiasedInterruptTime");
494 pRtlQueryPerformanceCounter = (void *)GetProcAddress(mod, "RtlQueryPerformanceCounter");
495 pRtlQueryPerformanceFrequency = (void *)GetProcAddress(mod, "RtlQueryPerformanceFrequency");
496
497 if (pRtlTimeToTimeFields && pRtlTimeFieldsToTime)
499 else
500 win_skip("Required time conversion functions are not available\n");
504#if (defined(__i386__) || defined(__x86_64__)) && !defined(__arm64ec__)
505 test_RtlQueryPerformanceCounter();
506#endif
508}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:68
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define win_skip
Definition: minitest.h:67
static void test_NtQueryPerformanceCounter(void)
Definition: time.c:115
static void test_user_shared_data_time(void)
Definition: time.c:415
static void test_pRtlTimeToTimeFields(void)
Definition: time.c:62
static void test_TimerResolution(void)
Definition: time.c:240
static void test_RtlQueryTimeZoneInformation(void)
Definition: time.c:336

◆ test_NtQueryPerformanceCounter()

static void test_NtQueryPerformanceCounter ( void  )
static

Definition at line 115 of file time.c.

116{
119
120 status = pNtQueryPerformanceCounter(NULL, NULL);
121 ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %08lx\n", status);
122 status = pNtQueryPerformanceCounter(NULL, &frequency);
123 ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %08lx\n", status);
124 status = pNtQueryPerformanceCounter(&counter, (void *)0xdeadbee0);
125 ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %08lx\n", status);
126 status = pNtQueryPerformanceCounter((void *)0xdeadbee0, &frequency);
127 ok(status == STATUS_ACCESS_VIOLATION, "expected STATUS_ACCESS_VIOLATION, got %08lx\n", status);
128
129 status = pNtQueryPerformanceCounter(&counter, NULL);
130 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08lx\n", status);
131 status = pNtQueryPerformanceCounter(&counter, &frequency);
132 ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08lx\n", status);
133}
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define STATUS_ACCESS_VIOLATION
static LARGE_INTEGER * frequency
Definition: time.c:38

Referenced by START_TEST().

◆ test_pRtlTimeToTimeFields()

static void test_pRtlTimeToTimeFields ( void  )
static

Definition at line 62 of file time.c.

63{
64 LARGE_INTEGER litime , liresult;
65 TIME_FIELDS tfresult;
66 int i=0;
67 litime.QuadPart = ((ULONGLONG)0x0144017a << 32) | 0xf0b0a980;
68 while( tftest.Year < 2110 ) {
69 /* test at the last second of the month */
70 pRtlTimeToTimeFields( &litime, &tfresult);
71 ok( tfresult.Year == tftest.Year && tfresult.Month == tftest.Month &&
72 tfresult.Day == tftest.Day && tfresult.Hour == tftest.Hour &&
73 tfresult.Minute == tftest.Minute && tfresult.Second == tftest.Second,
74 "#%d expected: %d-%d-%d %d:%d:%d got: %d-%d-%d %d:%d:%d\n", ++i,
77 tfresult.Year, tfresult.Month, tfresult.Day,
78 tfresult.Hour, tfresult.Minute, tfresult.Second);
79 /* test the inverse */
80 pRtlTimeFieldsToTime( &tfresult, &liresult);
81 ok( liresult.QuadPart == litime.QuadPart," TimeFieldsToTime failed on %d-%d-%d %d:%d:%d. Error is %d ticks\n",
82 tfresult.Year, tfresult.Month, tfresult.Day,
83 tfresult.Hour, tfresult.Minute, tfresult.Second,
84 (int) (liresult.QuadPart - litime.QuadPart) );
85 /* one second later is beginning of next month */
86 litime.QuadPart += TICKSPERSEC ;
87 pRtlTimeToTimeFields( &litime, &tfresult);
88 ok( tfresult.Year == tftest.Year + (tftest.Month ==12) &&
89 tfresult.Month == tftest.Month % 12 + 1 &&
90 tfresult.Day == 1 && tfresult.Hour == 0 &&
91 tfresult.Minute == 0 && tfresult.Second == 0,
92 "#%d expected: %d-%d-%d %d:%d:%d got: %d-%d-%d %d:%d:%d\n", ++i,
93 tftest.Year + (tftest.Month ==12),
94 tftest.Month % 12 + 1, 1, 0, 0, 0,
95 tfresult.Year, tfresult.Month, tfresult.Day,
96 tfresult.Hour, tfresult.Minute, tfresult.Second);
97 /* test the inverse */
98 pRtlTimeFieldsToTime( &tfresult, &liresult);
99 ok( liresult.QuadPart == litime.QuadPart," TimeFieldsToTime failed on %d-%d-%d %d:%d:%d. Error is %d ticks\n",
100 tfresult.Year, tfresult.Month, tfresult.Day,
101 tfresult.Hour, tfresult.Minute, tfresult.Second,
102 (int) (liresult.QuadPart - litime.QuadPart) );
103 /* advance to the end of the month */
104 litime.QuadPart -= TICKSPERSEC ;
105 if( tftest.Month == 12) {
106 tftest.Month = 1;
107 tftest.Year += 1;
108 } else
109 tftest.Month += 1;
112 }
113}
#define TICKSPERSEC
Definition: time.c:236
#define SECSPERDAY
Definition: time.c:233
static const int MonthLengths[2][12]
Definition: time.c:57
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
Definition: glfuncs.h:248
static TIME_FIELDS tftest
Definition: time.c:60
int64_t LONGLONG
Definition: typedefs.h:68
LONGLONG QuadPart
Definition: typedefs.h:114
#define IsLeapYear(y)
Definition: variant.c:1048

Referenced by START_TEST().

◆ test_RtlQueryTimeZoneInformation()

static void test_RtlQueryTimeZoneInformation ( void  )
static

Definition at line 336 of file time.c.

337{
338 RTL_DYNAMIC_TIME_ZONE_INFORMATION tzinfo, tzinfo2;
340 ULONG len;
341
342 /* test RtlQueryTimeZoneInformation returns an indirect string,
343 e.g. @tzres.dll,-32 (Vista or later) */
344 if (!pRtlQueryTimeZoneInformation || !pRtlQueryDynamicTimeZoneInformation)
345 {
346 win_skip("Time zone name tests require Vista or later\n");
347 return;
348 }
349
350 memset(&tzinfo, 0xcc, sizeof(tzinfo));
351 status = pRtlQueryDynamicTimeZoneInformation(&tzinfo);
353 "RtlQueryDynamicTimeZoneInformation failed, got %08lx\n", status);
354 ok(tzinfo.StandardName[0] == '@' ||
355 broken(tzinfo.StandardName[0]), /* some win10 2004 */
356 "standard time zone name isn't an indirect string, got %s\n",
358 ok(tzinfo.DaylightName[0] == '@' ||
359 broken(tzinfo.DaylightName[0]), /* some win10 2004 */
360 "daylight time zone name isn't an indirect string, got %s\n",
362
363 memset(&tzinfo2, 0xcc, sizeof(tzinfo2));
364 status = pNtQuerySystemInformation( SystemDynamicTimeZoneInformation, &tzinfo2, sizeof(tzinfo2), &len );
365 ok( !status, "NtQuerySystemInformation failed %lx\n", status );
366 ok( len == sizeof(tzinfo2), "wrong len %lu\n", len );
367 ok( !memcmp( &tzinfo, &tzinfo2, sizeof(tzinfo2) ), "tz data is different\n" );
368
369 memset(&tzinfo, 0xcc, sizeof(tzinfo));
370 status = pRtlQueryTimeZoneInformation((RTL_TIME_ZONE_INFORMATION *)&tzinfo);
372 "RtlQueryTimeZoneInformation failed, got %08lx\n", status);
373 ok(tzinfo.StandardName[0] == '@' ||
374 broken(tzinfo.StandardName[0]), /* some win10 2004 */
375 "standard time zone name isn't an indirect string, got %s\n",
377 ok(tzinfo.DaylightName[0] == '@' ||
378 broken(tzinfo.DaylightName[0]), /* some win10 2004 */
379 "daylight time zone name isn't an indirect string, got %s\n",
381
382 memset(&tzinfo, 0xcc, sizeof(tzinfo));
383 status = pRtlQueryTimeZoneInformation((RTL_TIME_ZONE_INFORMATION *)&tzinfo);
385 "RtlQueryTimeZoneInformation failed, got %08lx\n", status);
386 ok(tzinfo.StandardName[0] == '@' ||
387 broken(tzinfo.StandardName[0]), /* some win10 2004 */
388 "standard time zone name isn't an indirect string, got %s\n",
390 ok(tzinfo.DaylightName[0] == '@' ||
391 broken(tzinfo.DaylightName[0]), /* some win10 2004 */
392 "daylight time zone name isn't an indirect string, got %s\n",
394
395 memset(&tzinfo2, 0xcc, sizeof(tzinfo2));
396 status = pNtQuerySystemInformation( SystemCurrentTimeZoneInformation, &tzinfo2,
397 sizeof(RTL_TIME_ZONE_INFORMATION), &len );
398 ok( !status, "NtQuerySystemInformation failed %lx\n", status );
399 ok( len == sizeof(RTL_TIME_ZONE_INFORMATION), "wrong len %lu\n", len );
400 ok( !memcmp( &tzinfo, &tzinfo2, sizeof(RTL_TIME_ZONE_INFORMATION) ), "tz data is different\n" );
401}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
@ SystemCurrentTimeZoneInformation
Definition: ntddk_ex.h:59
GLenum GLsizei len
Definition: glext.h:6722
#define wine_dbgstr_w
Definition: kernel32.h:34
@ SystemDynamicTimeZoneInformation
Definition: extypes.h:321
#define memset(x, y, z)
Definition: compat.h:39
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ test_TimerResolution()

static void test_TimerResolution ( void  )
static

Definition at line 240 of file time.c.

241{
242 ULONG min, max, cur, min2, max2, cur2, set;
244
246 ok(status == STATUS_ACCESS_VIOLATION, "NtQueryTimerResolution(NULL,,) success\n");
247
249 ok(status == STATUS_ACCESS_VIOLATION, "NtQueryTimerResolution(,NULL,) success\n");
250
252 ok(status == STATUS_ACCESS_VIOLATION, "NtQueryTimerResolution(,,NULL) success\n");
253
254 min = 212121;
255 cur = min + 1;
256 max = cur + 1;
258 ok(status == STATUS_SUCCESS, "NtQueryTimerResolution() failed (%lx)\n", status);
259 ok(min == 156250 /* 1/64s HPET */ || min == 156001 /* RTC */,
260 "unexpected minimum timer resolution %lu\n", min);
261 ok(0 < max, "invalid maximum timer resolution, should be 0 < %lu\n", max);
262 ok(max <= cur || broken(max - TIMER_LEEWAY <= cur), "invalid timer resolutions, should be %lu <= %lu\n", max, cur);
263 ok(cur <= min || broken(cur <= min + TIMER_LEEWAY), "invalid timer resolutions, should be %lu <= %lu\n", cur, min);
264
266 ok(status == STATUS_ACCESS_VIOLATION, "NtSetTimerResolution(,,NULL) success\n");
267
268 /* Nothing happens if that pointer is not good */
270 ok(status == STATUS_ACCESS_VIOLATION, "NtSetTimerResolution() failed %lx\n", status);
271
272 min2 = min + 10000;
273 cur2 = min2 + 1;
274 max2 = cur2 + 1;
275 status = NtQueryTimerResolution(&min2, &max2, &cur2);
276 ok(status == STATUS_SUCCESS, "NtQueryTimerResolution() failed (%lx)\n", status);
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);
280
281 /* 'fails' until the first valid timer resolution request */
282 cur2 = 7654321;
283 status = NtSetTimerResolution(0, FALSE, &cur2);
284 ok(status == STATUS_TIMER_RESOLUTION_NOT_SET, "NtSetTimerResolution() failed %lx\n", status);
285 /* and returns the current timer resolution */
286 ok(cur2 == cur, "expected requested timer resolution %lu, got %lu\n", cur, cur2);
287
288
289 cur2 = 7654321;
290 status = NtSetTimerResolution(max - 1, TRUE, &cur2);
292
293 /* Rescinds our timer resolution request */
294 cur2 = 7654321;
295 status = NtSetTimerResolution(0, FALSE, &cur2);
296 ok(status == STATUS_SUCCESS, "NtSetTimerResolution() failed %lx\n", status);
297 /* -> the timer resolution was reset to its initial value */
298 ok(cur2 == cur, "expected requested timer resolution %lu, got %lu\n", min, cur2);
299
300 cur2 = 7654321;
301 status = NtSetTimerResolution(0, FALSE, &cur2);
302 ok(status == STATUS_TIMER_RESOLUTION_NOT_SET, "NtSetTimerResolution() failed %lx\n", status);
303 ok(cur2 == cur, "expected requested timer resolution %lu, got %lu\n", cur, cur2);
304
305 cur2 = 7654321;
306 status = NtSetTimerResolution(min + 1, TRUE, &cur2);
307 ok(status == STATUS_SUCCESS, "NtSetTimerResolution() failed %lx\n", status);
308 /* This works because:
309 * - Either cur is the minimum (15.6 ms) resolution already, i.e. the
310 * closest valid value 'set' is rounded to.
311 * - Or some other application requested a higher timer resolution, cur,
312 * and any attempt to lower the resolution has no effect until that
313 * request is rescinded (hopefully after this test is done).
314 */
316
317 /* The requested resolution may (win7) or may not be rounded */
318 cur2 = 7654321;
319 set = max < cur ? cur - 1 : max;
321 ok(status == STATUS_SUCCESS, "NtSetTimerResolution() failed %lx\n", status);
322 ok(cur2 <= set || broken(cur2 <= set + TIMER_LEEWAY), "expected new timer resolution %lu <= %lu\n", cur2, set);
323 trace("timer resolution: %lu(max) <= %lu(cur) <= %lu(prev) <= %lu(min)\n", max, cur2, cur, min);
324
325 cur2 = 7654321;
326 status = NtSetTimerResolution(cur + 1, TRUE, &cur2);
327 CHECK_CURRENT_TIMER(cur); /* see min + 1 test */
328
329 /* Cleanup by rescinding the last request */
330 cur2 = 7654321;
331 status = NtSetTimerResolution(0, FALSE, &cur2);
332 ok(status == STATUS_SUCCESS, "NtSetTimerResolution() failed %lx\n", status);
333 ok(cur2 == cur, "expected requested timer resolution %lu, got %lu\n", set, cur2);
334}
#define trace
Definition: atltest.h:70
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
FxCollectionEntry * cur
#define CHECK_CURRENT_TIMER(expected)
Definition: time.c:225
NTSTATUS NTAPI NtSetTimerResolution(IN ULONG DesiredResolution, IN BOOLEAN SetResolution, OUT PULONG CurrentResolution)
Definition: time.c:678
#define STATUS_TIMER_RESOLUTION_NOT_SET
Definition: ntstatus.h:835

Referenced by START_TEST().

◆ test_user_shared_data_time()

static void test_user_shared_data_time ( void  )
static

Definition at line 415 of file time.c.

416{
417 KSHARED_USER_DATA *user_shared_data = (void *)0x7ffe0000;
419 ULONGLONG t1, t2, t3;
421 int i = 0;
422
423 i = 0;
424 do
425 {
426 t1 = GetTickCount();
427 if (user_shared_data->NtMajorVersion <= 5 && user_shared_data->NtMinorVersion <= 1)
428 t2 = (DWORD)((*(volatile ULONG*)&user_shared_data->TickCountLowDeprecated * (ULONG64)user_shared_data->TickCountMultiplier) >> 24);
429 else
430 t2 = (DWORD)((read_ksystem_time(&user_shared_data->TickCount) * user_shared_data->TickCountMultiplier) >> 24);
431 t3 = GetTickCount();
432 } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */
433
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",
438
439 i = 0;
440 do
441 {
442 LARGE_INTEGER system_time;
443 NtQuerySystemTime(&system_time);
444 t1 = system_time.QuadPart;
445 t2 = read_ksystem_time(&user_shared_data->SystemTime);
446 NtQuerySystemTime(&system_time);
447 t3 = system_time.QuadPart;
448 } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */
449
450 /* FIXME: not always in order, but should be close */
451 todo_wine_if(t1 > t2 && t1 - t2 < 50 * TICKSPERMSEC)
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",
456
457 if (!pRtlQueryUnbiasedInterruptTime)
458 win_skip("skipping RtlQueryUnbiasedInterruptTime tests\n");
459 else
460 {
461 i = 0;
462 do
463 {
464 pRtlQueryUnbiasedInterruptTime(&t1);
465 t2 = read_ksystem_time(&user_shared_data->InterruptTime) - user_shared_data->InterruptTimeBias;
466 pRtlQueryUnbiasedInterruptTime(&t3);
467 } while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */
468
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",
473 }
474
475 t1 = read_ksystem_time(&user_shared_data->TimeZoneBias);
476 status = NtQuerySystemInformation(SystemTimeOfDayInformation, &timeofday, sizeof(timeofday), NULL);
477 ok(!status, "failed to query time of day, status %#lx\n", status);
478 ok(timeofday.TimeZoneBias.QuadPart == t1, "got USD bias %I64u, ntdll bias %I64u\n",
479 t1, timeofday.TimeZoneBias.QuadPart);
480}
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
static const struct _KUSER_SHARED_DATA * user_shared_data
Definition: sync.c:43
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
#define TICKSPERMSEC
Definition: time.c:237
@ SystemTimeOfDayInformation
Definition: ntddk_ex.h:14
#define todo_wine_if(is_todo)
Definition: minitest.h:81
unsigned __int64 ULONG64
Definition: imports.h:198
static ULONGLONG read_ksystem_time(volatile KSYSTEM_TIME *time)
Definition: time.c:403
#define DWORD
Definition: nt_native.h:44
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
Definition: time.c:563
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
LARGE_INTEGER TimeZoneBias
Definition: extypes.h:1034

Referenced by START_TEST().

◆ VOID()

static VOID ( WINAPI pRtlTimeToTimeFields) const
static

Variable Documentation

◆ frequency

◆ info

Definition at line 40 of file time.c.

◆ MonthLengths

const int MonthLengths[2][12]
static
Initial value:
=
{
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
}

Definition at line 48 of file time.c.

◆ ret_size

◆ size

Definition at line 40 of file time.c.

◆ tftest

TIME_FIELDS tftest = {1889,12,31,23,59,59,0,0}
static

Definition at line 60 of file time.c.

Referenced by test_pRtlTimeToTimeFields().

◆ Time

Definition at line 37 of file time.c.

Referenced by ClockPropertyCorrelatedPhysicalTime(), ClockPropertyCorrelatedTime(), ClockPropertyPhysicalTime(), ClockPropertyTime(), CompBattCalculateAtRateTime(), CompBattGetEstimatedTime(), CompBattQueryInformation(), CCabinet::ConvertDateAndTime(), ElfReportEventA(), ElfReportEventAndSourceW(), ElfReportEventW(), ElfrIntReportEventW(), ElfrReportEventA(), ElfrReportEventAndSourceW(), ElfrReportEventW(), ExpAllocateUuids(), ExpUuidGetValues(), ExUuidCreate(), FatConstructDirent(), FatFatDateToNtTime(), FatFatTimeToNtTime(), FatGetCurrentFatTime(), FatSwapDirEntry(), FatSwapFatXDirEntry(), FormatDateTime(), FrLdrHeapAllocateEx(), FrLdrHeapFreeEx(), GdiSAPCallback(), GetCurrentDayOfMonth(), GetCurrentTimeInSeconds(), GetLocalSystemTime(), GetNtTimeout(), GetQueuedCompletionStatus(), GetTimeAsJobTime(), GetTimeInSeconds(), HalQueryRealTimeClock(), HalSetRealTimeClock(), Host_Sleep(), IntDispatchMessage(), JobTimeToTimeString(), KiCheckForTimerExpiration(), KiReadSystemTime(), KiTimerExpiration(), KsGetDefaultClockTime(), CKsProxy::KsGetPhysicalTime(), CKsProxy::KsGetTime(), KspBusWorkerRoutine(), KsServiceBusEnumCreateRequest(), KsServiceBusEnumPnpRequest(), KsSetDefaultClockTime(), CKsProxy::KsSetPhysicalTime(), CKsProxy::KsSetTime(), LogfAllocAndBuildNewRecord(), LogfReportEvent(), LsarCreateSecret(), LsarSetSecret(), LsarStorePrivateData(), MmeGetPosition(), MonthCalSetLocalTime(), NetrRemoteTOD(), NtAllocateUuids(), NtProcessStartup(), OnInitDialog(), ParseDate(), Ping(), PRINT_RECORD(), PrintDateTime(), PrintLocalTime(), ProcessPortMessage(), ProcessTest(), ProcessTimers(), QuerySystemTimeMs(), QueryTime(), ReportTimes(), RtlSecondsSince1970ToTime(), RtlSecondsSince1980ToTime(), RtlTimeFieldsToTime(), RtlTimeToElapsedTimeFields(), RtlTimeToSecondsSince1970(), RtlTimeToSecondsSince1980(), RtlTimeToTimeFields(), FxUsbDevice::SendSyncRequest(), FxUsbDevice::SendSyncUmUrb(), SetLocalSystemTime(), SetScreenSaver(), SignalObjectAndWait(), SleepConditionVariableCS(), SleepConditionVariableSRW(), SleepEx(), START_TEST(), TdiDisconnect(), Time2Str(), TimeToMsString(), USBPORT_StartTimer(), WaitForMultipleObjectsEx(), WaitForSingleObjectEx(), WDF_ABS_TIMEOUT_IN_MS(), WDF_ABS_TIMEOUT_IN_SEC(), WDF_ABS_TIMEOUT_IN_US(), WDF_REL_TIMEOUT_IN_MS(), WDF_REL_TIMEOUT_IN_SEC(), WDF_REL_TIMEOUT_IN_US(), WdmAudGetWavePositionByLegacy(), WdmAudGetWavePositionByMMixer(), and xclip_handle_SelectionNotify().

◆ TimeFields