Commit 13e11d3f authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

kernel32: Move the implementation of GetTickCount() to kernel32.

parent 81e16e90
...@@ -858,8 +858,8 @@ ...@@ -858,8 +858,8 @@
@ stdcall GetThreadPriorityBoost(long ptr) @ stdcall GetThreadPriorityBoost(long ptr)
@ stdcall GetThreadSelectorEntry(long long ptr) @ stdcall GetThreadSelectorEntry(long long ptr)
@ stdcall GetThreadTimes(long ptr ptr ptr ptr) @ stdcall GetThreadTimes(long ptr ptr ptr ptr)
@ stdcall GetTickCount() ntdll.NtGetTickCount @ stdcall GetTickCount()
@ stdcall -ret64 GetTickCount64() ntdll.NtGetTickCount @ stdcall -ret64 GetTickCount64()
@ stdcall GetTimeFormatA(long long ptr str ptr long) @ stdcall GetTimeFormatA(long long ptr str ptr long)
@ stdcall GetTimeFormatEx(wstr long ptr wstr ptr long) @ stdcall GetTimeFormatEx(wstr long ptr wstr ptr long)
@ stdcall GetTimeFormatW(long long ptr wstr ptr long) @ stdcall GetTimeFormatW(long long ptr wstr ptr long)
......
...@@ -38,6 +38,9 @@ ...@@ -38,6 +38,9 @@
#elif defined(HAVE_MACHINE_LIMITS_H) #elif defined(HAVE_MACHINE_LIMITS_H)
#include <machine/limits.h> #include <machine/limits.h>
#endif #endif
#ifdef __APPLE__
# include <mach/mach_time.h>
#endif
#include "ntstatus.h" #include "ntstatus.h"
#define WIN32_NO_STATUS #define WIN32_NO_STATUS
...@@ -64,6 +67,33 @@ static inline LONGLONG filetime_to_longlong( const FILETIME *ft ) ...@@ -64,6 +67,33 @@ static inline LONGLONG filetime_to_longlong( const FILETIME *ft )
return (((LONGLONG)ft->dwHighDateTime) << 32) + ft->dwLowDateTime; return (((LONGLONG)ft->dwHighDateTime) << 32) + ft->dwLowDateTime;
} }
#define TICKSPERSEC 10000000
#define TICKSPERMSEC 10000
/* return a monotonic time counter, in Win32 ticks */
static inline ULONGLONG monotonic_counter(void)
{
LARGE_INTEGER counter;
#ifdef __APPLE__
static mach_timebase_info_data_t timebase;
if (!timebase.denom) mach_timebase_info( &timebase );
return mach_absolute_time() * timebase.numer / timebase.denom / 100;
#elif defined(HAVE_CLOCK_GETTIME)
struct timespec ts;
#ifdef CLOCK_MONOTONIC_RAW
if (!clock_gettime( CLOCK_MONOTONIC_RAW, &ts ))
return ts.tv_sec * (ULONGLONG)TICKSPERSEC + ts.tv_nsec / 100;
#endif
if (!clock_gettime( CLOCK_MONOTONIC, &ts ))
return ts.tv_sec * (ULONGLONG)TICKSPERSEC + ts.tv_nsec / 100;
#endif
NtQueryPerformanceCounter( &counter, NULL );
return counter.QuadPart;
}
static const WCHAR mui_stdW[] = { 'M','U','I','_','S','t','d',0 }; static const WCHAR mui_stdW[] = { 'M','U','I','_','S','t','d',0 };
static const WCHAR mui_dltW[] = { 'M','U','I','_','D','l','t',0 }; static const WCHAR mui_dltW[] = { 'M','U','I','_','D','l','t',0 };
...@@ -1528,3 +1558,30 @@ BOOL WINAPI QueryUnbiasedInterruptTime(ULONGLONG *time) ...@@ -1528,3 +1558,30 @@ BOOL WINAPI QueryUnbiasedInterruptTime(ULONGLONG *time)
RtlQueryUnbiasedInterruptTime(time); RtlQueryUnbiasedInterruptTime(time);
return TRUE; return TRUE;
} }
/******************************************************************************
* GetTickCount64 (KERNEL32.@)
*/
ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void)
{
return monotonic_counter() / TICKSPERMSEC;
}
/***********************************************************************
* GetTickCount (KERNEL32.@)
*
* Get the number of milliseconds the system has been running.
*
* PARAMS
* None.
*
* RETURNS
* The current tick count.
*
* NOTES
* The value returned will wrap around every 2^32 milliseconds.
*/
DWORD WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
{
return monotonic_counter() / TICKSPERMSEC;
}
...@@ -194,7 +194,7 @@ ...@@ -194,7 +194,7 @@
@ stdcall NtGetCurrentProcessorNumber() @ stdcall NtGetCurrentProcessorNumber()
# @ stub NtGetDevicePowerState # @ stub NtGetDevicePowerState
@ stub NtGetPlugPlayEvent @ stub NtGetPlugPlayEvent
@ stdcall -ret64 NtGetTickCount() get_tick_count64 @ stdcall NtGetTickCount()
@ stdcall NtGetWriteWatch(long long ptr long ptr ptr ptr) @ stdcall NtGetWriteWatch(long long ptr long ptr ptr ptr)
@ stdcall NtImpersonateAnonymousToken(long) @ stdcall NtImpersonateAnonymousToken(long)
@ stub NtImpersonateClientOfPort @ stub NtImpersonateClientOfPort
...@@ -1142,7 +1142,7 @@ ...@@ -1142,7 +1142,7 @@
@ stdcall -private ZwGetCurrentProcessorNumber() NtGetCurrentProcessorNumber @ stdcall -private ZwGetCurrentProcessorNumber() NtGetCurrentProcessorNumber
# @ stub ZwGetDevicePowerState # @ stub ZwGetDevicePowerState
@ stub ZwGetPlugPlayEvent @ stub ZwGetPlugPlayEvent
@ stdcall -private -ret64 ZwGetTickCount() get_tick_count64 @ stdcall -private ZwGetTickCount() NtGetTickCount
@ stdcall -private ZwGetWriteWatch(long long ptr long ptr ptr ptr) NtGetWriteWatch @ stdcall -private ZwGetWriteWatch(long long ptr long ptr ptr ptr) NtGetWriteWatch
@ stdcall -private ZwImpersonateAnonymousToken(long) NtImpersonateAnonymousToken @ stdcall -private ZwImpersonateAnonymousToken(long) NtImpersonateAnonymousToken
@ stub ZwImpersonateClientOfPort @ stub ZwImpersonateClientOfPort
......
...@@ -268,8 +268,4 @@ void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR); ...@@ -268,8 +268,4 @@ void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR);
/* string functions */ /* string functions */
int __cdecl NTDLL_tolower( int c ); int __cdecl NTDLL_tolower( int c );
int __cdecl _stricmp( LPCSTR str1, LPCSTR str2 ); int __cdecl _stricmp( LPCSTR str1, LPCSTR str2 );
/* time functions */
ULONGLONG WINAPI get_tick_count64( void );
#define NtGetTickCount get_tick_count64
#endif #endif
...@@ -557,7 +557,7 @@ NTSTATUS WINAPI NtQueryPerformanceCounter( LARGE_INTEGER *counter, LARGE_INTEGER ...@@ -557,7 +557,7 @@ NTSTATUS WINAPI NtQueryPerformanceCounter( LARGE_INTEGER *counter, LARGE_INTEGER
* NtGetTickCount (NTDLL.@) * NtGetTickCount (NTDLL.@)
* ZwGetTickCount (NTDLL.@) * ZwGetTickCount (NTDLL.@)
*/ */
ULONGLONG WINAPI DECLSPEC_HOTPATCH get_tick_count64(void) ULONG WINAPI NtGetTickCount(void)
{ {
return monotonic_counter() / TICKSPERMSEC; return monotonic_counter() / TICKSPERMSEC;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment