ntdll: Move RtlGetSystemTimePrecise() to the Unix library.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-06-25 18:07:38 +02:00
parent 13c1f008c0
commit b8dc6b2412
6 changed files with 25 additions and 28 deletions

View File

@ -32,9 +32,6 @@
#include <string.h>
#include <limits.h>
#include <time.h>
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
@ -399,27 +396,7 @@ NTSTATUS WINAPI NtQuerySystemTime( LARGE_INTEGER *time )
*/
LONGLONG WINAPI RtlGetSystemTimePrecise( void )
{
LONGLONG time;
#ifdef HAVE_CLOCK_GETTIME
struct timespec ts;
if (!clock_gettime( CLOCK_REALTIME, &ts ))
{
time = ts.tv_sec * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
time += (ts.tv_nsec + 50) / 100;
}
else
#endif
{
struct timeval now;
gettimeofday( &now, 0 );
time = now.tv_sec * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
time += now.tv_usec * 10;
}
return time;
return unix_funcs->RtlGetSystemTimePrecise();
}
/******************************************************************************

View File

@ -1450,6 +1450,7 @@ static struct unix_funcs unix_funcs =
NtWriteVirtualMemory,
NtYieldExecution,
DbgUiIssueRemoteBreakin,
RtlGetSystemTimePrecise,
RtlWaitOnAddress,
RtlWakeAddressAll,
RtlWakeAddressSingle,

View File

@ -679,7 +679,7 @@ unsigned int server_wait( const select_op_t *select_op, data_size_t size, UINT f
{
LARGE_INTEGER now;
RtlQueryPerformanceCounter(&now);
NtQueryPerformanceCounter( &now, NULL );
abs_timeout -= now.QuadPart;
}

View File

@ -1044,7 +1044,7 @@ NTSTATUS WINAPI NtQueryTimer( HANDLE handle, TIMER_INFORMATION_CLASS class,
if (basic_info->RemainingTime.QuadPart > 0) NtQuerySystemTime( &now );
else
{
RtlQueryPerformanceCounter( &now );
NtQueryPerformanceCounter( &now, NULL );
basic_info->RemainingTime.QuadPart = -basic_info->RemainingTime.QuadPart;
}
@ -1242,6 +1242,23 @@ ULONG WINAPI NtGetTickCount(void)
}
/******************************************************************************
* RtlGetSystemTimePrecise (NTDLL.@)
*/
LONGLONG WINAPI RtlGetSystemTimePrecise(void)
{
struct timeval now;
#ifdef HAVE_CLOCK_GETTIME
struct timespec ts;
if (!clock_gettime( CLOCK_REALTIME, &ts ))
return ts.tv_sec * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970 + (ts.tv_nsec + 50) / 100;
#endif
gettimeofday( &now, 0 );
return now.tv_sec * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970 + now.tv_usec * 10;
}
/******************************************************************************
* NtCreateKeyedEvent (NTDLL.@)
*/
@ -2248,7 +2265,7 @@ NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size
{
LARGE_INTEGER now;
RtlQueryPerformanceCounter(&now);
NtQueryPerformanceCounter( &now, NULL );
abs_timeout -= now.QuadPart;
}

View File

@ -89,6 +89,7 @@ extern NTSTATUS CDECL fast_RtlSleepConditionVariableCS( RTL_CONDITION_VARIABLE *
RTL_CRITICAL_SECTION *cs,
const LARGE_INTEGER *timeout ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL fast_RtlWakeConditionVariable( RTL_CONDITION_VARIABLE *variable, int count ) DECLSPEC_HIDDEN;
extern LONGLONG CDECL fast_RtlGetSystemTimePrecise(void) DECLSPEC_HIDDEN;
void CDECL mmap_add_reserved_area( void *addr, SIZE_T size ) DECLSPEC_HIDDEN;
void CDECL mmap_remove_reserved_area( void *addr, SIZE_T size ) DECLSPEC_HIDDEN;

View File

@ -29,7 +29,7 @@ struct msghdr;
struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 62
#define NTDLL_UNIXLIB_VERSION 63
struct unix_funcs
{
@ -261,6 +261,7 @@ struct unix_funcs
/* other Win32 API functions */
NTSTATUS (WINAPI *DbgUiIssueRemoteBreakin)( HANDLE process );
LONGLONG (WINAPI *RtlGetSystemTimePrecise)(void);
NTSTATUS (WINAPI *RtlWaitOnAddress)( const void *addr, const void *cmp, SIZE_T size,
const LARGE_INTEGER *timeout );
void (WINAPI *RtlWakeAddressAll)( const void *addr );