Author: sginsberg
Date: Tue Jan 6 13:57:44 2009
New Revision: 38616
URL:
http://svn.reactos.org/svn/reactos?rev=38616&view=rev
Log:
- NtUserWaitForInputIdle: Call EngGetTickCount, removing duplicated code
- GetTickCount/GetTickCount64/EngGetTickCount: Use the correct SharedUserData fields, and
fix the calculations
- KeUpdateSystemTime: Don't update TickCountLowDeprecated now that it truly is
deprecated
- Thanks to Fireball and KJK!
Modified:
trunk/reactos/dll/win32/kernel32/misc/time.c
trunk/reactos/ntoskrnl/ke/i386/systimer.S
trunk/reactos/ntoskrnl/ke/powerpc/ppc_irq.c
trunk/reactos/subsystems/win32/win32k/ntuser/message.c
trunk/reactos/subsystems/win32/win32k/stubs/stubs.c
Modified: trunk/reactos/dll/win32/kernel32/misc/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/ti…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/time.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/time.c [iso-8859-1] Tue Jan 6 13:57:44 2009
@@ -578,7 +578,8 @@
WINAPI
GetTickCount(VOID)
{
- return (DWORD)((ULONGLONG)SharedUserData->TickCountLowDeprecated *
SharedUserData->TickCountMultiplier / 16777216);
+ /* Call the 64-bit version */
+ return (DWORD)GetTickCount64();
}
@@ -589,7 +590,25 @@
WINAPI
GetTickCount64(VOID)
{
- return (ULONGLONG)SharedUserData->TickCountLowDeprecated *
(ULONGLONG)SharedUserData->TickCountMultiplier / 16777216;
+ ULONG Multiplier;
+ LARGE_INTEGER TickCount;
+
+ /* Loop until we get a perfect match */
+ for (;;)
+ {
+ /* Read the tick count value */
+ TickCount.HighPart = SharedUserData->TickCount.High1Time;
+ TickCount.LowPart = SharedUserData->TickCount.LowPart;
+ if (TickCount.HighPart == SharedUserData->TickCount.High2Time) break;
+ YieldProcessor();
+ }
+
+ /* Get the multiplier */
+ Multiplier = SharedUserData->TickCountMultiplier;
+
+ /* Convert to milliseconds and return */
+ return (Int64ShrlMod32(UInt32x32To64(Multiplier, TickCount.LowPart), 24) +
+ (Multiplier * (TickCount.HighPart << 8)));
}
Modified: trunk/reactos/ntoskrnl/ke/i386/systimer.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/systimer.…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/systimer.S [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/systimer.S [iso-8859-1] Tue Jan 6 13:57:44 2009
@@ -294,9 +294,6 @@
mov ds:[USER_SHARED_DATA+USER_SHARED_DATA_TICK_COUNT], ecx
mov ds:[USER_SHARED_DATA+USER_SHARED_DATA_TICK_COUNT+4], edx
- /* FIXME: HACK */
- mov ds:[USER_SHARED_DATA], ecx
-
/* Get hand index and entry into the table */
and eax, TIMER_TABLE_SIZE - 1
shl eax, 4
Modified: trunk/reactos/ntoskrnl/ke/powerpc/ppc_irq.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/powerpc/ppc_ir…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/powerpc/ppc_irq.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/powerpc/ppc_irq.c [iso-8859-1] Tue Jan 6 13:57:44 2009
@@ -349,9 +349,6 @@
SharedUserData->TickCount.LowPart = Time.LowPart;
SharedUserData->TickCount.High1Time = Time.HighPart;
- /* Update tick count in shared user data as well */
- SharedUserData->TickCountLowDeprecated++;
-
/* Queue a DPC that will expire timers */
KeInsertQueueDpc(&KiExpireTimerDpc, 0, 0);
}
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Tue Jan 6
13:57:44 2009
@@ -2239,8 +2239,7 @@
return STATUS_SUCCESS; /* no event to wait on */
}
- StartTime = ((ULONGLONG)SharedUserData->TickCountLowDeprecated *
- SharedUserData->TickCountMultiplier / 16777216);
+ StartTime = EngGetTickCount();
Run = dwMilliseconds;
@@ -2294,9 +2293,7 @@
if (dwMilliseconds != INFINITE)
{
- Elapsed = ((ULONGLONG)SharedUserData->TickCountLowDeprecated *
- SharedUserData->TickCountMultiplier / 16777216)
- - StartTime;
+ Elapsed = EngGetTickCount() - StartTime;
if (Elapsed > Run)
Status = STATUS_TIMEOUT;
Modified: trunk/reactos/subsystems/win32/win32k/stubs/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/st…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/stubs/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/stubs/stubs.c [iso-8859-1] Tue Jan 6 13:57:44
2009
@@ -2888,12 +2888,21 @@
UNIMPLEMENTED;
return FALSE;
}
-
+
ULONGLONG
APIENTRY
EngGetTickCount(VOID)
{
- return ((ULONGLONG)SharedUserData->TickCountLowDeprecated *
SharedUserData->TickCountMultiplier / 16777216);
+ ULONG Multiplier;
+ LARGE_INTEGER TickCount;
+
+ /* Get the multiplier and current tick count */
+ KeQueryTickCount(&TickCount);
+ Multiplier = SharedUserData->TickCountMultiplier;
+
+ /* Convert to milliseconds and return */
+ return (Int64ShrlMod32(UInt32x32To64(Multiplier, TickCount.LowPart), 24) +
+ (Multiplier * (TickCount.HighPart << 8)));
}
BOOLEAN