Alexandre Julliard : ntdll: Move RtlGetSystemTimePrecise() to the Unix library.
Alexandre Julliard
julliard at winehq.org
Thu Jun 25 16:14:25 CDT 2020
Module: wine
Branch: master
Commit: b8dc6b241204f5348563a23f51765234ef19f044
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b8dc6b241204f5348563a23f51765234ef19f044
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Jun 25 18:07:38 2020 +0200
ntdll: Move RtlGetSystemTimePrecise() to the Unix library.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/time.c | 25 +------------------------
dlls/ntdll/unix/loader.c | 1 +
dlls/ntdll/unix/server.c | 2 +-
dlls/ntdll/unix/sync.c | 21 +++++++++++++++++++--
dlls/ntdll/unix/unix_private.h | 1 +
dlls/ntdll/unixlib.h | 3 ++-
6 files changed, 25 insertions(+), 28 deletions(-)
diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c
index 3174a39c2c..d6466b9dd1 100644
--- a/dlls/ntdll/time.c
+++ b/dlls/ntdll/time.c
@@ -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();
}
/******************************************************************************
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index d8f7ab1bf0..68018b49fb 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -1450,6 +1450,7 @@ static struct unix_funcs unix_funcs =
NtWriteVirtualMemory,
NtYieldExecution,
DbgUiIssueRemoteBreakin,
+ RtlGetSystemTimePrecise,
RtlWaitOnAddress,
RtlWakeAddressAll,
RtlWakeAddressSingle,
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index 299a311496..f02d1ed8a2 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -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;
}
diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c
index bcf5fef017..4402584f28 100644
--- a/dlls/ntdll/unix/sync.c
+++ b/dlls/ntdll/unix/sync.c
@@ -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;
}
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index 1f06c91eff..ee6caaec8f 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -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;
diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h
index 3f93b961a6..62117eabb6 100644
--- a/dlls/ntdll/unixlib.h
+++ b/dlls/ntdll/unixlib.h
@@ -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 );
More information about the wine-cvs
mailing list