Use getpagesize() instead of VIRTUAL_GetPageSize().

This commit is contained in:
Alexandre Julliard 2000-12-13 20:22:47 +00:00
parent 982a223f36
commit 6c8edaa667
6 changed files with 14 additions and 66 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -8,9 +8,10 @@
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#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;

View File

@ -10,12 +10,10 @@
#include <string.h>
#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;

View File

@ -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();

View File

@ -22,6 +22,7 @@
#include <string.h>
#include <stdarg.h>
#include <time.h>
#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 );