ntdll: Move the system information functions to the Unix library.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-06-23 14:29:31 +02:00
parent 577b392440
commit 9b9845e43e
13 changed files with 2621 additions and 2638 deletions

View File

@ -59,6 +59,7 @@ C_SRCS = \
unix/signal_i386.c \
unix/signal_x86_64.c \
unix/sync.c \
unix/system.c \
unix/tape.c \
unix/thread.c \
unix/virtual.c \

View File

@ -3942,14 +3942,13 @@ void __wine_process_init(void)
UNICODE_STRING nt_name;
HMODULE ntdll_module = (HMODULE)((__wine_spec_nt_header.OptionalHeader.ImageBase + 0xffff) & ~0xffff);
INITIAL_TEB stack;
BOOL suspend;
SIZE_T info_size;
TEB *teb;
PEB *peb;
if (!unix_funcs) load_ntdll_so( ntdll_module, &__wine_spec_nt_header );
teb = thread_init( &info_size, &suspend );
teb = thread_init( &info_size );
peb = teb->Peb;
peb->ProcessHeap = RtlCreateHeap( HEAP_GROWABLE, NULL, 0, 0, NULL, NULL );
peb->LoaderLock = &loader_section;

File diff suppressed because it is too large Load Diff

View File

@ -64,9 +64,8 @@ extern LPCSTR debugstr_ObjectAttributes(const OBJECT_ATTRIBUTES *oa) DECLSPEC_HI
/* init routines */
extern void version_init(void) DECLSPEC_HIDDEN;
extern void debug_init(void) DECLSPEC_HIDDEN;
extern TEB *thread_init( SIZE_T *info_size, BOOL *suspend ) DECLSPEC_HIDDEN;
extern TEB *thread_init( SIZE_T *info_size ) DECLSPEC_HIDDEN;
extern void actctx_init(void) DECLSPEC_HIDDEN;
extern void fill_cpu_info(void) DECLSPEC_HIDDEN;
extern void heap_set_debug_flags( HANDLE handle ) DECLSPEC_HIDDEN;
extern void init_unix_codepage(void) DECLSPEC_HIDDEN;
extern void init_locale( HMODULE module ) DECLSPEC_HIDDEN;
@ -78,8 +77,6 @@ extern NTSTATUS restart_process( RTL_USER_PROCESS_PARAMETERS *params, NTSTATUS s
extern const char *build_dir DECLSPEC_HIDDEN;
extern const char *data_dir DECLSPEC_HIDDEN;
extern const char *config_dir DECLSPEC_HIDDEN;
extern timeout_t server_start_time DECLSPEC_HIDDEN;
extern unsigned int server_cpus DECLSPEC_HIDDEN;
extern BOOL is_wow64 DECLSPEC_HIDDEN;
extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret,
data_size_t *ret_len ) DECLSPEC_HIDDEN;
@ -147,8 +144,6 @@ static inline struct ntdll_thread_data *ntdll_get_thread_data(void)
return (struct ntdll_thread_data *)&NtCurrentTeb()->GdiTebBatch;
}
extern SYSTEM_CPU_INFORMATION cpu_info DECLSPEC_HIDDEN;
#define HASH_STRING_ALGORITHM_DEFAULT 0
#define HASH_STRING_ALGORITHM_X65599 1
#define HASH_STRING_ALGORITHM_INVALID 0xffffffff

View File

@ -40,11 +40,8 @@ const char *build_dir = NULL;
const char *data_dir = NULL;
const char *config_dir = NULL;
unsigned int server_cpus = 0;
BOOL is_wow64 = FALSE;
timeout_t server_start_time = 0; /* time of server startup */
/***********************************************************************
* wine_server_call (NTDLL.@)
*

View File

@ -106,15 +106,6 @@ extern DWORD EXC_CallHandler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_R
CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **dispatcher,
PEXCEPTION_HANDLER handler, PEXCEPTION_HANDLER nested_handler );
/***********************************************************************
* has_fpux
*/
static inline int has_fpux(void)
{
return (cpu_info.FeatureSet & CPU_FEATURE_FXSR);
}
/*******************************************************************
* is_valid_frame
*/
@ -304,7 +295,6 @@ static inline void save_fpux( CONTEXT *context )
char buffer[sizeof(XMM_SAVE_AREA32) + 16];
XMM_SAVE_AREA32 *state = (XMM_SAVE_AREA32 *)(((ULONG_PTR)buffer + 15) & ~15);
if (!has_fpux()) return;
context->ContextFlags |= CONTEXT_EXTENDED_REGISTERS;
__asm__ __volatile__( "fxsave %0" : "=m" (*state) );
memcpy( context->ExtendedRegisters, state, sizeof(*state) );

View File

@ -102,10 +102,10 @@ int __cdecl __wine_dbg_output( const char *str )
*
* NOTES: The first allocated TEB on NT is at 0x7ffde000.
*/
TEB *thread_init( SIZE_T *info_size, BOOL *suspend )
TEB *thread_init( SIZE_T *info_size )
{
TEB *teb = unix_funcs->init_threading( &nb_threads, &__wine_ldt_copy, info_size, suspend, &server_cpus,
&is_wow64, &server_start_time );
ULONG_PTR val;
TEB *teb = unix_funcs->init_threading( &nb_threads, &__wine_ldt_copy, info_size );
peb = teb->Peb;
peb->FastPebLock = &peb_lock;
@ -137,7 +137,8 @@ TEB *thread_init( SIZE_T *info_size, BOOL *suspend )
peb->SessionId = 1;
unix_funcs->get_paths( &build_dir, &data_dir, &config_dir );
fill_cpu_info();
NtQueryInformationProcess( GetCurrentProcess(), ProcessWow64Information, &val, sizeof(val), NULL );
is_wow64 = !!val;
return teb;
}

View File

@ -1392,6 +1392,7 @@ static struct unix_funcs unix_funcs =
NtOpenSemaphore,
NtOpenThread,
NtOpenTimer,
NtPowerInformation,
NtProtectVirtualMemory,
NtPulseEvent,
NtQueryAttributesFile,
@ -1407,6 +1408,8 @@ static struct unix_funcs unix_funcs =
NtQueryPerformanceCounter,
NtQuerySection,
NtQuerySemaphore,
NtQuerySystemInformation,
NtQuerySystemInformationEx,
NtQuerySystemTime,
NtQueryTimer,
NtQueryVirtualMemory,
@ -1477,7 +1480,6 @@ static struct unix_funcs unix_funcs =
get_build_id,
get_host_version,
virtual_map_section,
virtual_get_system_info,
virtual_alloc_thread_stack,
virtual_locked_recvmsg,
virtual_release_address_space,

2575
dlls/ntdll/unix/system.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -84,10 +84,10 @@ static void pthread_exit_wrapper( int status )
/***********************************************************************
* init_threading
*/
TEB * CDECL init_threading( int *nb_threads_ptr, struct ldt_copy **ldt_copy, SIZE_T *size, BOOL *suspend,
unsigned int *cpus, BOOL *wow64, timeout_t *start_time )
TEB * CDECL init_threading( int *nb_threads_ptr, struct ldt_copy **ldt_copy, SIZE_T *size )
{
TEB *teb;
BOOL suspend;
SIZE_T info_size;
#ifdef __i386__
extern struct ldt_copy __wine_ldt_copy;
@ -102,16 +102,14 @@ TEB * CDECL init_threading( int *nb_threads_ptr, struct ldt_copy **ldt_copy, SIZ
signal_init_thread( teb );
dbg_init();
server_init_process();
info_size = server_init_thread( teb->Peb, suspend );
info_size = server_init_thread( teb->Peb, &suspend );
virtual_map_user_shared_data();
virtual_create_builtin_view( ntdll_module );
init_cpu_info();
init_files();
NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
if (size) *size = info_size;
if (cpus) *cpus = server_cpus;
if (wow64) *wow64 = is_wow64;
if (start_time) *start_time = server_start_time;
return teb;
}

View File

@ -102,7 +102,6 @@ extern void CDECL get_locales( WCHAR *sys, WCHAR *user ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL virtual_map_section( HANDLE handle, PVOID *addr_ptr, unsigned short zero_bits_64, SIZE_T commit_size,
const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG alloc_type,
ULONG protect, pe_image_info_t *image_info ) DECLSPEC_HIDDEN;
extern void CDECL virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size, SIZE_T *pthread_size ) DECLSPEC_HIDDEN;
extern ssize_t CDECL virtual_locked_recvmsg( int fd, struct msghdr *hdr, int flags ) DECLSPEC_HIDDEN;
extern void CDECL virtual_release_address_space(void) DECLSPEC_HIDDEN;
@ -115,9 +114,7 @@ extern NTSTATUS CDECL server_handle_to_fd( HANDLE handle, unsigned int access, i
unsigned int *options ) DECLSPEC_HIDDEN;
extern void CDECL server_release_fd( HANDLE handle, int unix_fd ) DECLSPEC_HIDDEN;
extern void CDECL server_init_process_done( void *relay ) DECLSPEC_HIDDEN;
extern TEB * CDECL init_threading( int *nb_threads_ptr, struct ldt_copy **ldt_copy, SIZE_T *size,
BOOL *suspend, unsigned int *cpus, BOOL *wow64,
timeout_t *start_time ) DECLSPEC_HIDDEN;
extern TEB * CDECL init_threading( int *nb_threads_ptr, struct ldt_copy **ldt_copy, SIZE_T *size ) DECLSPEC_HIDDEN;
extern void CDECL DECLSPEC_NORETURN exit_thread( int status ) DECLSPEC_HIDDEN;
extern void CDECL DECLSPEC_NORETURN exit_process( int status ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status ) DECLSPEC_HIDDEN;
@ -183,6 +180,7 @@ extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct o
extern void virtual_init(void) DECLSPEC_HIDDEN;
extern ULONG_PTR get_system_affinity_mask(void) DECLSPEC_HIDDEN;
extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_create_builtin_view( void *module ) DECLSPEC_HIDDEN;
extern TEB *virtual_alloc_first_teb(void) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_alloc_teb( TEB **ret_teb ) DECLSPEC_HIDDEN;
@ -226,6 +224,7 @@ extern NTSTATUS tape_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTI
extern NTSTATUS errno_to_status( int err ) DECLSPEC_HIDDEN;
extern void init_files(void) DECLSPEC_HIDDEN;
extern void init_cpu_info(void) DECLSPEC_HIDDEN;
extern void dbg_init(void) DECLSPEC_HIDDEN;
@ -278,6 +277,13 @@ static inline WCHAR *ntdll_wcschr( const WCHAR *str, WCHAR ch )
return NULL;
}
static inline WCHAR *ntdll_wcsrchr( const WCHAR *str, WCHAR ch )
{
WCHAR *ret = NULL;
do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
return ret;
}
static inline WCHAR *ntdll_wcspbrk( const WCHAR *str, const WCHAR *accept )
{
for ( ; *str; str++) if (ntdll_wcschr( accept, *str )) return (WCHAR *)(ULONG_PTR)str;
@ -326,6 +332,7 @@ static inline int ntdll_wcsnicmp( const WCHAR *str1, const WCHAR *str2, int n )
#define wcscmp(s1,s2) ntdll_wcscmp(s1,s2)
#define wcsncmp(s1,s2,n) ntdll_wcsncmp(s1,s2,n)
#define wcschr(str,ch) ntdll_wcschr(str,ch)
#define wcsrchr(str,ch) ntdll_wcsrchr(str,ch)
#define wcspbrk(str,ac) ntdll_wcspbrk(str,ac)
#define wcsicmp(s1, s2) ntdll_wcsicmp(s1,s2)
#define wcsnicmp(s1, s2,n) ntdll_wcsnicmp(s1,s2,n)

View File

@ -2468,7 +2468,7 @@ ULONG_PTR get_system_affinity_mask(void)
/***********************************************************************
* virtual_get_system_info
*/
void CDECL virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info )
void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info )
{
#ifdef HAVE_SYSINFO
struct sysinfo sinfo;

View File

@ -28,7 +28,7 @@ struct ldt_copy;
struct msghdr;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 59
#define NTDLL_UNIXLIB_VERSION 60
struct unix_funcs
{
@ -139,6 +139,8 @@ struct unix_funcs
NTSTATUS (WINAPI *NtOpenThread)( HANDLE *handle, ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr, const CLIENT_ID *id );
NTSTATUS (WINAPI *NtOpenTimer)( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr );
NTSTATUS (WINAPI *NtPowerInformation)( POWER_INFORMATION_LEVEL level, void *input, ULONG in_size,
void *output, ULONG out_size );
NTSTATUS (WINAPI *NtProtectVirtualMemory)( HANDLE process, PVOID *addr_ptr, SIZE_T *size_ptr,
ULONG new_prot, ULONG *old_prot );
NTSTATUS (WINAPI *NtPulseEvent)( HANDLE handle, LONG *prev_state );
@ -170,6 +172,11 @@ struct unix_funcs
void *ptr, SIZE_T size, SIZE_T *ret_size );
NTSTATUS (WINAPI *NtQuerySemaphore)( HANDLE handle, SEMAPHORE_INFORMATION_CLASS class,
void *info, ULONG len, ULONG *ret_len );
NTSTATUS (WINAPI *NtQuerySystemInformation)( SYSTEM_INFORMATION_CLASS class,
void *info, ULONG size, ULONG *ret_size );
NTSTATUS (WINAPI *NtQuerySystemInformationEx)( SYSTEM_INFORMATION_CLASS class,
void *query, ULONG query_len,
void *info, ULONG size, ULONG *ret_size );
NTSTATUS (WINAPI *NtQuerySystemTime)( LARGE_INTEGER *time );
NTSTATUS (WINAPI *NtQueryTimer)( HANDLE handle, TIMER_INFORMATION_CLASS class,
void *info, ULONG len, ULONG *ret_len );
@ -291,15 +298,13 @@ struct unix_funcs
NTSTATUS (CDECL *virtual_map_section)( HANDLE handle, PVOID *addr_ptr, unsigned short zero_bits_64, SIZE_T commit_size,
const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG alloc_type,
ULONG protect, pe_image_info_t *image_info );
void (CDECL *virtual_get_system_info)( SYSTEM_BASIC_INFORMATION *info );
NTSTATUS (CDECL *virtual_alloc_thread_stack)( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size, SIZE_T *pthread_size );
ssize_t (CDECL *virtual_locked_recvmsg)( int fd, struct msghdr *hdr, int flags );
void (CDECL *virtual_release_address_space)(void);
void (CDECL *virtual_set_large_address_space)(void);
/* thread/process functions */
TEB * (CDECL *init_threading)( int *nb_threads_ptr, struct ldt_copy **ldt_copy, SIZE_T *size,
BOOL *suspend, unsigned int *cpus, BOOL *wow64, timeout_t *start_time );
TEB * (CDECL *init_threading)( int *nb_threads_ptr, struct ldt_copy **ldt_copy, SIZE_T *size );
void (CDECL *exit_thread)( int status );
void (CDECL *exit_process)( int status );
NTSTATUS (CDECL *exec_process)( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status );