Module: wine Branch: master Commit: 4b65a7027f42a7c754f13e3639febb767fcf1780 URL: https://gitlab.winehq.org/wine/wine/-/commit/4b65a7027f42a7c754f13e3639febb7...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Nov 10 10:34:52 2022 +0100
ntdll: Use a proper Unix syscall for RtlGetSystemTimePrecise().
---
dlls/ntdll/loader.c | 25 ------------------------- dlls/ntdll/ntdll.spec | 1 - dlls/ntdll/ntdll_misc.h | 1 - dlls/ntdll/time.c | 5 ++++- dlls/ntdll/unix/loader.c | 20 ++------------------ dlls/ntdll/unix/sync.c | 11 ++++++++--- dlls/ntdll/unix/unix_private.h | 1 + dlls/ntdll/unixlib.h | 9 +-------- 8 files changed, 16 insertions(+), 57 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index f5a07b510c9..5c7c2592018 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -4600,28 +4600,3 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) if (reason == DLL_PROCESS_ATTACH) LdrDisableThreadCalloutsForDll( inst ); return TRUE; } - - -static LONGLONG WINAPI RtlGetSystemTimePrecise_fallback(void) -{ - LARGE_INTEGER now; - NtQuerySystemTime( &now ); - return now.QuadPart; -} - -static const struct unix_funcs unix_fallbacks = -{ - RtlGetSystemTimePrecise_fallback, -}; - -const struct unix_funcs *unix_funcs = &unix_fallbacks; - -/*********************************************************************** - * __wine_set_unix_funcs - */ -NTSTATUS CDECL __wine_set_unix_funcs( int version, const struct unix_funcs *funcs ) -{ - if (version != NTDLL_UNIXLIB_VERSION) return STATUS_REVISION_MISMATCH; - unix_funcs = funcs; - return STATUS_SUCCESS; -} diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 74e37fccbb6..7a5a5afdb6b 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1692,7 +1692,6 @@ # Unix interface @ stdcall -syscall __wine_unix_call(int64 long ptr) @ stdcall -syscall __wine_unix_spawnvp(long ptr) -@ cdecl __wine_set_unix_funcs(long ptr) @ stdcall __wine_ctrl_routine(ptr) @ extern __wine_syscall_dispatcher @ extern -arch=i386 __wine_ldt_copy diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 1ce972e3b38..36972a966f1 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -85,7 +85,6 @@ extern const WCHAR windows_dir[] DECLSPEC_HIDDEN; extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
extern void (FASTCALL *pBaseThreadInitThunk)(DWORD,LPTHREAD_START_ROUTINE,void *) DECLSPEC_HIDDEN; -extern const struct unix_funcs *unix_funcs DECLSPEC_HIDDEN;
extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c index ccd2c55552b..0a4ff0f64d3 100644 --- a/dlls/ntdll/time.c +++ b/dlls/ntdll/time.c @@ -372,7 +372,10 @@ void WINAPI RtlTimeToElapsedTimeFields( const LARGE_INTEGER *Time, PTIME_FIELDS */ LONGLONG WINAPI RtlGetSystemTimePrecise( void ) { - return unix_funcs->RtlGetSystemTimePrecise(); + LONGLONG ret; + + NTDLL_UNIX_CALL( system_time_precise, &ret ); + return ret; }
/****************************************************************************** diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 3f16d2f0086..35f2e5f986f 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -116,7 +116,6 @@ void (WINAPI *pRtlUserThreadStart)( PRTL_THREAD_START_ROUTINE entry, void *a void (WINAPI *p__wine_ctrl_routine)(void*); SYSTEM_DLL_INIT_BLOCK *pLdrSystemDllInitBlock = NULL;
-static NTSTATUS (CDECL *p__wine_set_unix_funcs)( int version, const struct unix_funcs *funcs ); static void *p__wine_syscall_dispatcher;
static void * const syscalls[] = @@ -1062,7 +1061,6 @@ static void load_ntdll_functions( HMODULE module ) GET_FUNC( LdrSystemDllInitBlock ); GET_FUNC( RtlUserThreadStart ); GET_FUNC( __wine_ctrl_routine ); - GET_FUNC( __wine_set_unix_funcs ); GET_FUNC( __wine_syscall_dispatcher ); #ifdef __i386__ { @@ -2150,15 +2148,6 @@ static ULONG_PTR get_image_address(void) }
-/*********************************************************************** - * unix_funcs - */ -static struct unix_funcs unix_funcs = -{ - RtlGetSystemTimePrecise, -}; - - /*********************************************************************** * __wine_unix_call_funcs */ @@ -2167,6 +2156,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] = load_so_dll, init_builtin_dll, unwind_builtin_dll, + system_time_precise, };
@@ -2182,6 +2172,7 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] = wow64_load_so_dll, wow64_init_builtin_dll, wow64_unwind_builtin_dll, + system_time_precise, };
@@ -2191,7 +2182,6 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] = static void start_main_thread(void) { SYSTEM_SERVICE_TABLE syscall_table = { (ULONG_PTR *)syscalls, NULL, ARRAY_SIZE(syscalls), syscall_args }; - NTSTATUS status; TEB *teb = virtual_alloc_first_teb();
signal_init_threading(); @@ -2214,12 +2204,6 @@ static void start_main_thread(void) if (main_image_info.Machine != current_machine) load_wow64_ntdll( main_image_info.Machine ); load_apiset_dll(); ntdll_init_syscalls( 0, &syscall_table, p__wine_syscall_dispatcher ); - status = p__wine_set_unix_funcs( NTDLL_UNIXLIB_VERSION, &unix_funcs ); - if (status == STATUS_REVISION_MISMATCH) - { - ERR( "ntdll library version mismatch\n" ); - NtTerminateProcess( GetCurrentProcess(), status ); - } server_init_process_done(); }
diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index 821a1f08311..9112572c67d 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -1642,17 +1642,22 @@ ULONG WINAPI NtGetTickCount(void) /****************************************************************************** * RtlGetSystemTimePrecise (NTDLL.@) */ -LONGLONG WINAPI RtlGetSystemTimePrecise(void) +NTSTATUS system_time_precise( void *args ) { + LONGLONG *ret = args; struct timeval now; #ifdef HAVE_CLOCK_GETTIME struct timespec ts;
if (!clock_gettime( CLOCK_REALTIME, &ts )) - return ticks_from_time_t( ts.tv_sec ) + (ts.tv_nsec + 50) / 100; + { + *ret = ticks_from_time_t( ts.tv_sec ) + (ts.tv_nsec + 50) / 100; + return STATUS_SUCCESS; + } #endif gettimeofday( &now, 0 ); - return ticks_from_time_t( now.tv_sec ) + now.tv_usec * 10; + *ret = ticks_from_time_t( now.tv_sec ) + now.tv_usec * 10; + return STATUS_SUCCESS; }
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 9e3db02fe47..b94a27aca68 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -192,6 +192,7 @@ extern NTSTATUS set_thread_context( HANDLE handle, const void *context, BOOL *se extern NTSTATUS get_thread_context( HANDLE handle, void *context, BOOL *self, USHORT machine ) DECLSPEC_HIDDEN; extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret, data_size_t *ret_len ) DECLSPEC_HIDDEN; +extern NTSTATUS system_time_precise( void *args ) DECLSPEC_HIDDEN;
extern void *anon_mmap_fixed( void *start, size_t size, int prot, int flags ) DECLSPEC_HIDDEN; extern void *anon_mmap_alloc( size_t size, int prot ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h index 59cd6b48788..97d93ba1724 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h @@ -43,18 +43,11 @@ enum ntdll_unix_funcs unix_load_so_dll, unix_init_builtin_dll, unix_unwind_builtin_dll, + unix_system_time_precise, };
extern unixlib_handle_t ntdll_unix_handle;
#define NTDLL_UNIX_CALL( func, params ) __wine_unix_call( ntdll_unix_handle, unix_ ## func, params )
-/* increment this when you change the function table */ -#define NTDLL_UNIXLIB_VERSION 138 - -struct unix_funcs -{ - LONGLONG (WINAPI *RtlGetSystemTimePrecise)(void); -}; - #endif /* __NTDLL_UNIXLIB_H */