[KERNEL32] Fix GetTickCount on 64 bit architecture
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 10 May 2014 08:37:45 +0000 (08:37 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 10 May 2014 08:37:45 +0000 (08:37 +0000)
[RTL] Implement RtlGetTickCount (currently a copy of GetTickCount from kernel32)
[NTDLL] Export RtlGetTickCount as NtGetTickCount and ZwGetTickCount

svn path=/trunk/; revision=63211

reactos/dll/ntdll/def/ntdll.spec
reactos/dll/ntdll/rtl/libsupp.c
reactos/dll/win32/kernel32/client/time.c
reactos/lib/rtl/rtlp.h

index e6f8799..c649d57 100644 (file)
 @ stdcall NtGetCurrentProcessorNumber() ; 5.2 and higher
 @ stdcall NtGetDevicePowerState(ptr ptr)
 @ stdcall NtGetPlugPlayEvent(long long ptr long)
-@ stdcall -stub NtGetTickCount()
+@ stdcall NtGetTickCount() RtlGetTickCount
 @ stdcall NtGetWriteWatch(long long ptr long ptr ptr ptr)
 @ stdcall NtImpersonateAnonymousToken(ptr)
 @ stdcall NtImpersonateClientOfPort(ptr ptr)
 @ stdcall ZwGetCurrentProcessorNumber()
 @ stdcall ZwGetDevicePowerState(ptr ptr)
 @ stdcall ZwGetPlugPlayEvent(long long ptr long)
-;@ stdcall ZwGetTickCount() NtGetTickCount
+@ stdcall ZwGetTickCount() RtlGetTickCount
 @ stdcall ZwGetWriteWatch(long long ptr long ptr ptr ptr) NtGetWriteWatch
 @ stdcall ZwImpersonateAnonymousToken(ptr)
 @ stdcall ZwImpersonateClientOfPort(ptr ptr) NtImpersonateClientOfPort
index 9ceb2b0..69d58f3 100644 (file)
@@ -613,4 +613,32 @@ RtlpSafeCopyMemory(
     return STATUS_SUCCESS;
 }
 
+/* FIXME: code duplication with kernel32/client/time.c */
+ULONG
+NTAPI
+RtlGetTickCount(VOID)
+{
+    ULARGE_INTEGER TickCount;
+
+#ifdef _WIN64
+    TickCount.QuadPart = *((volatile ULONG64*)&SharedUserData->TickCount);
+#else
+    while (TRUE)
+    {
+        TickCount.HighPart = (ULONG)SharedUserData->TickCount.High1Time;
+        TickCount.LowPart = SharedUserData->TickCount.LowPart;
+
+        if (TickCount.HighPart == (ULONG)SharedUserData->TickCount.High2Time)
+            break;
+
+        YieldProcessor();
+    }
+#endif
+
+    return (ULONG)((UInt32x32To64(TickCount.LowPart,
+                                  SharedUserData->TickCountMultiplier) >> 24) +
+                    UInt32x32To64((TickCount.HighPart << 8) & 0xFFFFFFFF,
+                                  SharedUserData->TickCountMultiplier));
+}
+
 /* EOF */
index aee6d8a..abba55b 100644 (file)
@@ -446,6 +446,9 @@ GetTickCount(VOID)
 {
     ULARGE_INTEGER TickCount;
 
+#ifdef _WIN64
+    TickCount.QuadPart = *((volatile ULONG64*)&SharedUserData->TickCount);
+#else
     while (TRUE)
     {
         TickCount.HighPart = (ULONG)SharedUserData->TickCount.High1Time;
@@ -456,6 +459,7 @@ GetTickCount(VOID)
 
         YieldProcessor();
     }
+#endif
 
     return (ULONG)((UInt32x32To64(TickCount.LowPart,
                                   SharedUserData->TickCountMultiplier) >> 24) +
index 634357b..b9429af 100644 (file)
@@ -125,6 +125,11 @@ RtlpHandleDpcStackException(IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
 #define RtlpAllocateStringMemory RtlpAllocateMemory
 #define RtlpFreeStringMemory     RtlpFreeMemory
 
+ULONG
+NTAPI
+RtlGetTickCount(VOID);
+#define NtGetTickCount RtlGetTickCount
+
 BOOLEAN
 NTAPI
 RtlpSetInDbgPrint(