ntdll: Use the user shared data to implement RtlQueryUnbiasedInterruptTime().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Alexandre Julliard 2020-05-21 17:07:20 +02:00
parent cc5953048e
commit 9b12068c6c
2 changed files with 12 additions and 3 deletions

View File

@ -222,8 +222,6 @@ static void test_user_shared_data_time(void)
pRtlQueryUnbiasedInterruptTime(&t3);
} while(t3 < t1 && i++ < 1); /* allow for wrap, but only once */
/* FIXME: not always in order, but should be close */
todo_wine_if(t1 > t2 && t1 - t2 < 50 * TICKSPERMSEC)
ok(t1 <= t2, "USD InterruptTime / RtlQueryUnbiasedInterruptTime are out of order %s %s\n",
wine_dbgstr_longlong(t1), wine_dbgstr_longlong(t2));
ok(t2 <= t3 || broken(t2 == t3 + 82410089070) /* w864 has some weird offset on testbot */,

View File

@ -47,6 +47,7 @@
#define NONAMELESSUNION
#include "windef.h"
#include "winternl.h"
#include "ddk/wdm.h"
#include "wine/exception.h"
#include "wine/debug.h"
#include "ntdll_misc.h"
@ -1128,11 +1129,21 @@ NTSTATUS WINAPI NtSetSystemTime(const LARGE_INTEGER *NewTime, LARGE_INTEGER *Old
*/
BOOL WINAPI RtlQueryUnbiasedInterruptTime(ULONGLONG *time)
{
ULONG high, low;
if (!time)
{
RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_PARAMETER );
return FALSE;
}
*time = monotonic_counter();
do
{
high = user_shared_data->InterruptTime.High1Time;
low = user_shared_data->InterruptTime.LowPart;
}
while (high != user_shared_data->InterruptTime.High2Time);
/* FIXME: should probably subtract InterruptTimeBias */
*time = (ULONGLONG)high << 32 | low;
return TRUE;
}