From 6c8edaa66749c796abd78175336c9432cd556ff4 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 13 Dec 2000 20:22:47 +0000 Subject: [PATCH] Use getpagesize() instead of VIRTUAL_GetPageSize(). --- include/global.h | 7 +------ memory/virtual.c | 50 +++------------------------------------------ misc/cpu.c | 5 +++-- msdos/xms.c | 4 +--- scheduler/sysdeps.c | 4 +--- win32/device.c | 10 ++++----- 6 files changed, 14 insertions(+), 66 deletions(-) diff --git a/include/global.h b/include/global.h index 987e0c6dd90..89bd38b6b21 100644 --- a/include/global.h +++ b/include/global.h @@ -9,6 +9,7 @@ #include "windef.h" #include "wine/windef16.h" +#include "wine/library.h" /* memory/global.c */ extern HGLOBAL16 GLOBAL_CreateBlock( UINT16 flags, const void *ptr, DWORD size, @@ -18,12 +19,6 @@ extern BOOL16 GLOBAL_MoveBlock( HGLOBAL16 handle, const void *ptr, DWORD size ); extern HGLOBAL16 GLOBAL_Alloc( WORD flags, DWORD size, HGLOBAL16 hOwner, unsigned char selflags ); /* memory/virtual.c */ -extern DWORD VIRTUAL_GetPageSize(void); -extern DWORD VIRTUAL_GetGranularity(void); -extern LPVOID VIRTUAL_MapFileW( LPCWSTR name ); -extern LPVOID VIRTUAL_mmap( int unix_handle, LPVOID start, DWORD size, - DWORD offset, int prot, int flags ); - typedef BOOL (*HANDLERPROC)(LPVOID, LPCVOID); extern BOOL VIRTUAL_SetFaultHandler(LPCVOID addr, HANDLERPROC proc, LPVOID arg); extern DWORD VIRTUAL_HandleFault(LPCVOID addr); diff --git a/memory/virtual.c b/memory/virtual.c index 321681f978a..e1043366650 100644 --- a/memory/virtual.c +++ b/memory/virtual.c @@ -103,6 +103,7 @@ static UINT page_size; #define VIRTUAL_DEBUG_DUMP_VIEW(view) \ if (!TRACE_ON(virtual)); else VIRTUAL_DumpView(view) +static LPVOID VIRTUAL_mmap( int fd, LPVOID start, DWORD size, DWORD offset, int prot, int flags ); /* filter for page-fault exceptions */ static WINE_EXCEPTION_FILTER(page_fault) @@ -591,24 +592,6 @@ DECL_GLOBAL_CONSTRUCTOR(VIRTUAL_Init) #endif /* page_mask */ -/*********************************************************************** - * VIRTUAL_GetPageSize - */ -DWORD VIRTUAL_GetPageSize(void) -{ - return 1 << page_shift; -} - - -/*********************************************************************** - * VIRTUAL_GetGranularity - */ -DWORD VIRTUAL_GetGranularity(void) -{ - return granularity_mask + 1; -} - - /*********************************************************************** * VIRTUAL_SetFaultHandler */ @@ -661,8 +644,8 @@ DWORD VIRTUAL_HandleFault( LPCVOID addr ) * Wrapper for mmap() that handles anonymous mappings portably, * and falls back to read if mmap of a file fails. */ -LPVOID VIRTUAL_mmap( int fd, LPVOID start, DWORD size, - DWORD offset, int prot, int flags ) +static LPVOID VIRTUAL_mmap( int fd, LPVOID start, DWORD size, + DWORD offset, int prot, int flags ) { int pos; LPVOID ret; @@ -1646,30 +1629,3 @@ BOOL WINAPI UnmapViewOfFile( VIRTUAL_DeleteView( view ); return TRUE; } - -/*********************************************************************** - * VIRTUAL_MapFileW - * - * Helper function to map a file to memory: - * name - file name - * [RETURN] ptr - pointer to mapped file - */ -LPVOID VIRTUAL_MapFileW( LPCWSTR name ) -{ - HANDLE hFile, hMapping; - LPVOID ptr = NULL; - - hFile = CreateFileW( name, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, 0); - if (hFile != INVALID_HANDLE_VALUE) - { - hMapping = CreateFileMappingA( hFile, NULL, PAGE_READONLY, 0, 0, NULL ); - CloseHandle( hFile ); - if (hMapping) - { - ptr = MapViewOfFile( hMapping, FILE_MAP_READ, 0, 0, 0 ); - CloseHandle( hMapping ); - } - } - return ptr; -} diff --git a/misc/cpu.c b/misc/cpu.c index dc665e790a2..44fb4030586 100644 --- a/misc/cpu.c +++ b/misc/cpu.c @@ -8,9 +8,10 @@ #include #include #include +#include "config.h" +#include "wine/port.h" #include "winbase.h" #include "winreg.h" -#include "global.h" #include "winnt.h" #include "winerror.h" #include "debugtools.h" @@ -55,7 +56,7 @@ VOID WINAPI GetSystemInfo( * FIXME: perhaps overrideable with precompiler flags? */ cachedsi.u.s.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL; - cachedsi.dwPageSize = VIRTUAL_GetPageSize(); + cachedsi.dwPageSize = getpagesize(); /* FIXME: the two entries below should be computed somehow... */ cachedsi.lpMinimumApplicationAddress = (void *)0x00010000; diff --git a/msdos/xms.c b/msdos/xms.c index d4f8e321377..eaf727c2a90 100644 --- a/msdos/xms.c +++ b/msdos/xms.c @@ -10,12 +10,10 @@ #include #include "winbase.h" #include "wine/winbase16.h" -#include "global.h" #include "module.h" #include "miscemu.h" #include "toolhelp.h" #include "debugtools.h" -#include "selectors.h" DEFAULT_DEBUG_CHANNEL(int31); @@ -58,7 +56,7 @@ void WINAPI XMS_Handler( CONTEXT86 *context ) mmi.dwSize = sizeof(mmi); MemManInfo16(&mmi); AX_reg(context) = mmi.dwLargestFreeBlock >> 10; - DX_reg(context) = (mmi.dwFreePages * VIRTUAL_GetPageSize()) >> 10; + DX_reg(context) = (mmi.dwFreePages * mmi.wPageSize) >> 10; TRACE("returning largest %dK, total %dK\n", AX_reg(context), DX_reg(context)); } break; diff --git a/scheduler/sysdeps.c b/scheduler/sysdeps.c index 4a837a3116b..4764f903652 100644 --- a/scheduler/sysdeps.c +++ b/scheduler/sysdeps.c @@ -29,10 +29,8 @@ static int *ph_errno = &h_errno; #endif #include "wine/port.h" #include "thread.h" -#include "selectors.h" #include "server.h" #include "winbase.h" -#include "global.h" #include "wine/exception.h" #include "debugtools.h" @@ -282,7 +280,7 @@ static LPVOID SYSDEPS_LargeStackLow = NULL; void SYSDEPS_SwitchToThreadStack( void (*func)(void) ) { - DWORD page_size = VIRTUAL_GetPageSize(); + DWORD page_size = getpagesize(); DWORD cur_stack = (((DWORD)&func) + (page_size-1)) & ~(page_size-1); TEB *teb = NtCurrentTeb(); diff --git a/win32/device.c b/win32/device.c index 4f5e1be95f6..e3fbab9092d 100644 --- a/win32/device.c +++ b/win32/device.c @@ -22,6 +22,7 @@ #include #include #include +#include "wine/port.h" #include "windef.h" #include "winbase.h" #include "winreg.h" @@ -35,7 +36,6 @@ #include "stackframe.h" #include "server.h" #include "debugtools.h" -#include "global.h" DEFAULT_DEBUG_CHANNEL(win32); @@ -678,7 +678,7 @@ static DWORD VxDCall_VMM( DWORD service, CONTEXT86 *context ) { LPVOID address; LPVOID ret; - DWORD psize = VIRTUAL_GetPageSize(); + DWORD psize = getpagesize(); ULONG page = (ULONG) stack32_pop( context ); ULONG npages = (ULONG) stack32_pop( context ); ULONG flags = (ULONG) stack32_pop( context ); @@ -708,7 +708,7 @@ static DWORD VxDCall_VMM( DWORD service, CONTEXT86 *context ) LPVOID address; LPVOID ret; DWORD virt_perm; - DWORD psize = VIRTUAL_GetPageSize(); + DWORD psize = getpagesize(); ULONG page = (ULONG) stack32_pop( context ); ULONG npages = (ULONG) stack32_pop( context ); ULONG hpd = (ULONG) stack32_pop( context ); @@ -737,7 +737,7 @@ static DWORD VxDCall_VMM( DWORD service, CONTEXT86 *context ) { LPVOID address; BOOL ret; - DWORD psize = VIRTUAL_GetPageSize(); + DWORD psize = getpagesize(); ULONG page = (ULONG) stack32_pop( context ); ULONG npages = (ULONG) stack32_pop( context ); ULONG flags = (ULONG) stack32_pop( context ); @@ -757,7 +757,7 @@ static DWORD VxDCall_VMM( DWORD service, CONTEXT86 *context ) DWORD virt_new_perm; MEMORY_BASIC_INFORMATION mbi; LPVOID address; - DWORD psize = VIRTUAL_GetPageSize(); + DWORD psize = getpagesize(); ULONG page = stack32_pop ( context ); ULONG npages = stack32_pop ( context ); ULONG permand = stack32_pop ( context );