mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 21:09:22 +08:00
* autoload.cc (NtCreateSection): Define.
* cygheap.cc (_csbrk): Call getpagesize instead of getshmlba. * dcrt0.cc (dll_crt0_0): Call mmap_init. * external.cc (cygwin_internal): Call getpagesize instead of getshmlba. * fhandler.h (fhandler_base::mmap): Change access to prot parameter. (fhandler_base::fixup_mmap_after_fork): Ditto. (fhandler_disk_file::mmap): Ditto. (fhandler_disk_file::fixup_mmap_after_fork): Ditto. (fhandler_dev_mem::mmap): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_mem.cc (fhandler_dev_mem::write): Call getsystempagesize instead of getpagesize. (fhandler_dev_mem::read): Ditto. (fhandler_dev_mem::fstat): Ditto. (fhandler_dev_mem::mmap): Move to mmap.cc. (fhandler_dev_mem::munmap): Ditto. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. * fhandler_proc.cc (format_proc_meminfo): Call getsystempagesize instead of getpagesize. * fhandler_process.cc (format_process_stat): Ditto. (format_process_status): Ditto. (get_mem_values): Ditto. * mmap.cc: Fix formatting. Try to make more readable and modular. Take advantage of pagesize==granularity. (gen_protect): New static function to evaluate Windows protection bits from POSIX protection and flags. (gen_access): Ditto for Windows access mode. (VirtualProt9x): Wrapper function to call VirtualProtect on 9x. (VirtualProtNT): Ditto for NT. (VirtualProtEx9x): Ditto for VirtualProtectEx on 9x. (VirtualProtExNT): Ditto for NT. (CreateMapping9x): Wrapper function for creating a mapping handle on 9x. (CreateMappingNT): Ditto for NT. (MapView9x): Wrapper function to map a view on 9x. (MapViewNT): Ditto for NT. (mmap_funcs_9x): Structure containing function pointers to wrapper functions for 9x. (mmap_funcs_nt): Ditto for NT. (mmap_func): Pointer to wrapper functions used in subsequent code. (mmap_init): Initialize mmap_func depending on OS. (class mmap_record): Use sensible member names. Add POSIX protection member. Drop Windows access flags member. Constify more methods. Use accessors instead of direct member access inside of own methods. (mmap_record::gen_protect): Class wrapper to evaluate matching Windows protection bits. (mmap_record::gen_access): Ditto for Windows access flags. (mmap_record::compatible_flags): New function to check if flags are compatible with flags of existing map. (list::add_record): Drop offset and length arguments. (class map): Change counters to unsigned. Match usage throughout. (mmapped_areas): Convert from pointer to global struct. (mmap_record::alloc_page_map): Simplify. (mmap_record::map_pages): Ditto. (mmap_record::fixup_page_map): Delete. (mmap64): Simplify. Add workaround for Windows 98 bug. Fix bug on NT that existing anonymous mappings weren't searched for a match. (munmap): Add workaround for Windows 98 bug. (msync): Simplify. (mprotect): Handle existing maps correctly. (mlock): Add local pagesize variable and enlightening comment. (fhandler_disk_file::mmap): Main functionality now in CreateMapping/ MapView wrapper functions. (fhandler_disk_file::fixup_mmap_after_fork): Call MapView wrapper. (fhandler_dev_mem::mmap): Moved from fhandler_mem.cc. Simplify by calling MapViewNT. (fhandler_dev_mem::munmap): Moved from fhandler_mem.cc. (fhandler_dev_mem::msync): Ditto. (fhandler_dev_mem::fixup_mmap_after_fork): Ditto. Call MapViewNT. (fixup_mmaps_after_fork): Restructure and hopefully speed up loop for setting protection and memory content on MAP_PRIVATE maps. * ntdll.h (AT_ROUND_TO_PAGE): Remove define. (AT_EXTENDABLE_FILE): Add define. (NtCreateSection): Add prototype. * syscalls.cc (getpagesize): Return granularity as pagesize now. (getsystempagesize): New function to retrieve "real" pagesize. (getshmlba): Delete since it's replaced by getpagesize now. * wincap.h (wincaps::has_mmap_alignment_bug): New element. * wincap.cc: Implement above element throughout. * winsup.h (getshmlba): Drop prototype. (getsystempagesize): Add prototype. (mmap_init): Ditto. * include/sys/mman.h: (Not yet) define MAP_NORESERVE.
This commit is contained in:
parent
87b69d9243
commit
f90e23f271
@ -1,3 +1,89 @@
|
||||
2005-11-28 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* autoload.cc (NtCreateSection): Define.
|
||||
* cygheap.cc (_csbrk): Call getpagesize instead of getshmlba.
|
||||
* dcrt0.cc (dll_crt0_0): Call mmap_init.
|
||||
* external.cc (cygwin_internal): Call getpagesize instead of getshmlba.
|
||||
* fhandler.h (fhandler_base::mmap): Change access to prot parameter.
|
||||
(fhandler_base::fixup_mmap_after_fork): Ditto.
|
||||
(fhandler_disk_file::mmap): Ditto.
|
||||
(fhandler_disk_file::fixup_mmap_after_fork): Ditto.
|
||||
(fhandler_dev_mem::mmap): Ditto.
|
||||
(fhandler_dev_mem::fixup_mmap_after_fork): Ditto.
|
||||
* fhandler_mem.cc (fhandler_dev_mem::write): Call getsystempagesize
|
||||
instead of getpagesize.
|
||||
(fhandler_dev_mem::read): Ditto.
|
||||
(fhandler_dev_mem::fstat): Ditto.
|
||||
(fhandler_dev_mem::mmap): Move to mmap.cc.
|
||||
(fhandler_dev_mem::munmap): Ditto.
|
||||
(fhandler_dev_mem::msync): Ditto.
|
||||
(fhandler_dev_mem::fixup_mmap_after_fork): Ditto.
|
||||
* fhandler_proc.cc (format_proc_meminfo): Call getsystempagesize
|
||||
instead of getpagesize.
|
||||
* fhandler_process.cc (format_process_stat): Ditto.
|
||||
(format_process_status): Ditto.
|
||||
(get_mem_values): Ditto.
|
||||
* mmap.cc: Fix formatting. Try to make more readable and modular.
|
||||
Take advantage of pagesize==granularity.
|
||||
(gen_protect): New static function to evaluate Windows
|
||||
protection bits from POSIX protection and flags.
|
||||
(gen_access): Ditto for Windows access mode.
|
||||
(VirtualProt9x): Wrapper function to call VirtualProtect on 9x.
|
||||
(VirtualProtNT): Ditto for NT.
|
||||
(VirtualProtEx9x): Ditto for VirtualProtectEx on 9x.
|
||||
(VirtualProtExNT): Ditto for NT.
|
||||
(CreateMapping9x): Wrapper function for creating a mapping handle on 9x.
|
||||
(CreateMappingNT): Ditto for NT.
|
||||
(MapView9x): Wrapper function to map a view on 9x.
|
||||
(MapViewNT): Ditto for NT.
|
||||
(mmap_funcs_9x): Structure containing function pointers to wrapper
|
||||
functions for 9x.
|
||||
(mmap_funcs_nt): Ditto for NT.
|
||||
(mmap_func): Pointer to wrapper functions used in subsequent code.
|
||||
(mmap_init): Initialize mmap_func depending on OS.
|
||||
(class mmap_record): Use sensible member names. Add POSIX protection
|
||||
member. Drop Windows access flags member. Constify more methods.
|
||||
Use accessors instead of direct member access inside of own methods.
|
||||
(mmap_record::gen_protect): Class wrapper to evaluate matching
|
||||
Windows protection bits.
|
||||
(mmap_record::gen_access): Ditto for Windows access flags.
|
||||
(mmap_record::compatible_flags): New function to check if flags are
|
||||
compatible with flags of existing map.
|
||||
(list::add_record): Drop offset and length arguments.
|
||||
(class map): Change counters to unsigned. Match usage throughout.
|
||||
(mmapped_areas): Convert from pointer to global struct.
|
||||
(mmap_record::alloc_page_map): Simplify.
|
||||
(mmap_record::map_pages): Ditto.
|
||||
(mmap_record::fixup_page_map): Delete.
|
||||
(mmap64): Simplify. Add workaround for Windows 98 bug. Fix bug on
|
||||
NT that existing anonymous mappings weren't searched for a match.
|
||||
(munmap): Add workaround for Windows 98 bug.
|
||||
(msync): Simplify.
|
||||
(mprotect): Handle existing maps correctly.
|
||||
(mlock): Add local pagesize variable and enlightening comment.
|
||||
(fhandler_disk_file::mmap): Main functionality now in CreateMapping/
|
||||
MapView wrapper functions.
|
||||
(fhandler_disk_file::fixup_mmap_after_fork): Call MapView wrapper.
|
||||
(fhandler_dev_mem::mmap): Moved from fhandler_mem.cc. Simplify by
|
||||
calling MapViewNT.
|
||||
(fhandler_dev_mem::munmap): Moved from fhandler_mem.cc.
|
||||
(fhandler_dev_mem::msync): Ditto.
|
||||
(fhandler_dev_mem::fixup_mmap_after_fork): Ditto. Call MapViewNT.
|
||||
(fixup_mmaps_after_fork): Restructure and hopefully speed up loop for
|
||||
setting protection and memory content on MAP_PRIVATE maps.
|
||||
* ntdll.h (AT_ROUND_TO_PAGE): Remove define.
|
||||
(AT_EXTENDABLE_FILE): Add define.
|
||||
(NtCreateSection): Add prototype.
|
||||
* syscalls.cc (getpagesize): Return granularity as pagesize now.
|
||||
(getsystempagesize): New function to retrieve "real" pagesize.
|
||||
(getshmlba): Delete since it's replaced by getpagesize now.
|
||||
* wincap.h (wincaps::has_mmap_alignment_bug): New element.
|
||||
* wincap.cc: Implement above element throughout.
|
||||
* winsup.h (getshmlba): Drop prototype.
|
||||
(getsystempagesize): Add prototype.
|
||||
(mmap_init): Ditto.
|
||||
* include/sys/mman.h: (Not yet) define MAP_NORESERVE.
|
||||
|
||||
2005-11-28 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Don't rely on
|
||||
|
@ -379,6 +379,7 @@ LoadDLLfunc (NetUserGetInfo, 16, netapi32)
|
||||
LoadDLLfunc (NetWkstaUserGetInfo, 12, netapi32)
|
||||
|
||||
LoadDLLfuncEx (NtCreateFile, 44, ntdll, 1)
|
||||
LoadDLLfuncEx (NtCreateSection, 28, ntdll, 1)
|
||||
LoadDLLfuncEx (NtCreateToken, 52, ntdll, 1)
|
||||
LoadDLLfuncEx (NtLockVirtualMemory, 16, ntdll, 1)
|
||||
LoadDLLfuncEx (NtMapViewOfSection, 40, ntdll, 1)
|
||||
|
@ -137,7 +137,7 @@ static void *__stdcall
|
||||
_csbrk (int sbs)
|
||||
{
|
||||
void *prebrk = cygheap_max;
|
||||
size_t granmask = getshmlba () - 1;
|
||||
size_t granmask = getpagesize () - 1;
|
||||
char *newbase = nextpage (prebrk);
|
||||
cygheap_max = (char *) cygheap_max + sbs;
|
||||
if (!sbs || (newbase > cygheap_max) || (cygheap_max < _cygheap_end))
|
||||
|
@ -646,6 +646,7 @@ dll_crt0_0 ()
|
||||
_impure_ptr->_current_locale = "C";
|
||||
wincap.init ();
|
||||
initial_env ();
|
||||
mmap_init ();
|
||||
|
||||
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
|
||||
GetCurrentProcess (), &hMainProc, 0, FALSE,
|
||||
|
@ -28,6 +28,7 @@ details. */
|
||||
#include "pwdgrp.h"
|
||||
#include "cygtls.h"
|
||||
#include "child_info.h"
|
||||
#include <unistd.h>
|
||||
|
||||
child_info *get_cygwin_startup_info ();
|
||||
|
||||
@ -267,7 +268,7 @@ cygwin_internal (cygwin_getinfo_types t, ...)
|
||||
}
|
||||
case CW_GET_SHMLBA:
|
||||
{
|
||||
return getshmlba ();
|
||||
return getpagesize ();
|
||||
}
|
||||
case CW_GET_UID_FROM_SID:
|
||||
{
|
||||
|
@ -298,11 +298,11 @@ class fhandler_base
|
||||
virtual int lock (int, struct __flock64 *);
|
||||
virtual int dup (fhandler_base *child);
|
||||
|
||||
virtual HANDLE mmap (caddr_t *addr, size_t len, DWORD access,
|
||||
virtual HANDLE mmap (caddr_t *addr, size_t len, int prot,
|
||||
int flags, _off64_t off);
|
||||
virtual int munmap (HANDLE h, caddr_t addr, size_t len);
|
||||
virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags);
|
||||
virtual bool fixup_mmap_after_fork (HANDLE h, DWORD access, int flags,
|
||||
virtual bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
|
||||
_off64_t offset, DWORD size,
|
||||
void *address);
|
||||
|
||||
@ -664,10 +664,10 @@ class fhandler_disk_file: public fhandler_base
|
||||
int __stdcall link (const char *) __attribute__ ((regparm (2)));
|
||||
int __stdcall utimes (const struct timeval *) __attribute__ ((regparm (2)));
|
||||
|
||||
HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, _off64_t off);
|
||||
HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, _off64_t off);
|
||||
int munmap (HANDLE h, caddr_t addr, size_t len);
|
||||
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
|
||||
bool fixup_mmap_after_fork (HANDLE h, DWORD access, int flags,
|
||||
bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
|
||||
_off64_t offset, DWORD size, void *address);
|
||||
int mkdir (mode_t mode);
|
||||
int rmdir ();
|
||||
@ -1083,10 +1083,10 @@ class fhandler_dev_mem: public fhandler_base
|
||||
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
|
||||
int dup (fhandler_base *child);
|
||||
|
||||
HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, _off64_t off);
|
||||
HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, _off64_t off);
|
||||
int munmap (HANDLE h, caddr_t addr, size_t len);
|
||||
int msync (HANDLE h, caddr_t addr, size_t len, int flags);
|
||||
bool fixup_mmap_after_fork (HANDLE h, DWORD access, int flags,
|
||||
bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
|
||||
_off64_t offset, DWORD size, void *address);
|
||||
} ;
|
||||
|
||||
|
@ -136,7 +136,7 @@ fhandler_dev_mem::write (const void *ptr, size_t ulen)
|
||||
PHYSICAL_ADDRESS phys;
|
||||
NTSTATUS ret;
|
||||
void *viewmem = NULL;
|
||||
DWORD len = ulen + getpagesize () - 1;
|
||||
DWORD len = ulen + getsystempagesize () - 1;
|
||||
|
||||
phys.QuadPart = (ULONGLONG) pos;
|
||||
if ((ret = NtMapViewOfSection (get_handle (),
|
||||
@ -188,7 +188,7 @@ fhandler_dev_mem::read (void *ptr, size_t& ulen)
|
||||
PHYSICAL_ADDRESS phys;
|
||||
NTSTATUS ret;
|
||||
void *viewmem = NULL;
|
||||
DWORD len = ulen + getpagesize () - 1;
|
||||
DWORD len = ulen + getsystempagesize () - 1;
|
||||
|
||||
phys.QuadPart = (ULONGLONG) pos;
|
||||
if ((ret = NtMapViewOfSection (get_handle (),
|
||||
@ -251,150 +251,11 @@ fhandler_dev_mem::lseek (_off64_t offset, int whence)
|
||||
return pos;
|
||||
}
|
||||
|
||||
HANDLE
|
||||
fhandler_dev_mem::mmap (caddr_t *addr, size_t len, DWORD access,
|
||||
int flags, _off64_t off)
|
||||
{
|
||||
if (off >= mem_size
|
||||
|| (DWORD) len >= mem_size
|
||||
|| off + len >= mem_size)
|
||||
{
|
||||
set_errno (EINVAL);
|
||||
syscall_printf ("-1 = mmap(): illegal parameter, set EINVAL");
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
UNICODE_STRING memstr;
|
||||
RtlInitUnicodeString (&memstr, L"\\device\\physicalmemory");
|
||||
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
InitializeObjectAttributes (&attr, &memstr,
|
||||
OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
|
||||
NULL, NULL);
|
||||
|
||||
ACCESS_MASK section_access;
|
||||
ULONG protect;
|
||||
|
||||
if (access & FILE_MAP_COPY)
|
||||
{
|
||||
section_access = SECTION_MAP_READ | SECTION_MAP_WRITE;
|
||||
protect = PAGE_WRITECOPY;
|
||||
}
|
||||
else if (access & FILE_MAP_WRITE)
|
||||
{
|
||||
section_access = SECTION_MAP_READ | SECTION_MAP_WRITE;
|
||||
protect = PAGE_READWRITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
section_access = SECTION_MAP_READ;
|
||||
protect = PAGE_READONLY;
|
||||
}
|
||||
|
||||
HANDLE h;
|
||||
NTSTATUS ret = NtOpenSection (&h, section_access, &attr);
|
||||
if (!NT_SUCCESS (ret))
|
||||
{
|
||||
__seterrno_from_nt_status (ret);
|
||||
syscall_printf ("-1 = mmap(): NtOpenSection failed with %E");
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
PHYSICAL_ADDRESS phys;
|
||||
void *base = *addr;
|
||||
DWORD dlen = len;
|
||||
|
||||
phys.QuadPart = (ULONGLONG) off;
|
||||
|
||||
if ((ret = NtMapViewOfSection (h,
|
||||
INVALID_HANDLE_VALUE,
|
||||
&base,
|
||||
0L,
|
||||
dlen,
|
||||
&phys,
|
||||
&dlen,
|
||||
ViewShare /*??*/,
|
||||
0,
|
||||
protect)) != STATUS_SUCCESS)
|
||||
{
|
||||
__seterrno_from_nt_status (ret);
|
||||
syscall_printf ("-1 = mmap(): NtMapViewOfSection failed with %E");
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if ((flags & MAP_FIXED) && base != *addr)
|
||||
{
|
||||
set_errno (EINVAL);
|
||||
syscall_printf ("-1 = mmap(): address shift with MAP_FIXED given");
|
||||
NtUnmapViewOfSection (INVALID_HANDLE_VALUE, base);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
*addr = (caddr_t) base;
|
||||
return h;
|
||||
}
|
||||
|
||||
int
|
||||
fhandler_dev_mem::munmap (HANDLE h, caddr_t addr, size_t len)
|
||||
{
|
||||
NTSTATUS ret;
|
||||
if (!NT_SUCCESS (ret = NtUnmapViewOfSection (INVALID_HANDLE_VALUE, addr)))
|
||||
{
|
||||
__seterrno_from_nt_status (ret);
|
||||
return -1;
|
||||
}
|
||||
CloseHandle (h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
fhandler_dev_mem::msync (HANDLE h, caddr_t addr, size_t len, int flags)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
fhandler_dev_mem::fixup_mmap_after_fork (HANDLE h, DWORD access, int flags,
|
||||
_off64_t offset, DWORD size,
|
||||
void *address)
|
||||
{
|
||||
DWORD ret;
|
||||
PHYSICAL_ADDRESS phys;
|
||||
void *base = address;
|
||||
DWORD dlen = size;
|
||||
ULONG protect;
|
||||
|
||||
if (access & FILE_MAP_COPY)
|
||||
protect = PAGE_WRITECOPY;
|
||||
else if (access & FILE_MAP_WRITE)
|
||||
protect = PAGE_READWRITE;
|
||||
else
|
||||
protect = PAGE_READONLY;
|
||||
|
||||
phys.QuadPart = (ULONGLONG) offset;
|
||||
|
||||
if ((ret = NtMapViewOfSection (h,
|
||||
INVALID_HANDLE_VALUE,
|
||||
&base,
|
||||
0L,
|
||||
dlen,
|
||||
&phys,
|
||||
&dlen,
|
||||
ViewShare /*??*/,
|
||||
0,
|
||||
protect)) != STATUS_SUCCESS)
|
||||
{
|
||||
__seterrno_from_nt_status (ret);
|
||||
syscall_printf ("-1 = fixup_mmap_after_fork(): NtMapViewOfSection failed with %E");
|
||||
return false;
|
||||
}
|
||||
return base == address;
|
||||
}
|
||||
|
||||
int
|
||||
fhandler_dev_mem::fstat (struct __stat64 *buf)
|
||||
{
|
||||
fhandler_base::fstat (buf);
|
||||
buf->st_blksize = getpagesize ();
|
||||
buf->st_blksize = getsystempagesize ();
|
||||
if (is_auto_device ())
|
||||
{
|
||||
buf->st_mode = S_IFCHR;
|
||||
|
@ -435,8 +435,9 @@ format_proc_meminfo (char *destbuf, size_t maxsize)
|
||||
PSYSTEM_PAGEFILE_INFORMATION spp = spi;
|
||||
do
|
||||
{
|
||||
swap_total += spp->CurrentSize * getpagesize ();
|
||||
swap_free += (spp->CurrentSize - spp->TotalUsed) * getpagesize ();
|
||||
swap_total += spp->CurrentSize * getsystempagesize ();
|
||||
swap_free += (spp->CurrentSize - spp->TotalUsed)
|
||||
* getsystempagesize ();
|
||||
}
|
||||
while (spp->NextEntryOffset
|
||||
&& (spp = (PSYSTEM_PAGEFILE_INFORMATION)
|
||||
|
@ -708,7 +708,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
|
||||
start_time = (spt.KernelTme.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL;
|
||||
#endif
|
||||
priority = pbi.BasePriority;
|
||||
unsigned page_size = getpagesize ();
|
||||
unsigned page_size = getsystempagesize ();
|
||||
vmsize = vmc.PagefileUsage;
|
||||
vmrss = vmc.WorkingSetSize / page_size;
|
||||
vmmaxrss = ql.MaximumWorkingSetSize / page_size;
|
||||
@ -788,7 +788,7 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
|
||||
{
|
||||
if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata, &vmlib, &vmshare))
|
||||
return 0;
|
||||
unsigned page_size = getpagesize ();
|
||||
unsigned page_size = getsystempagesize ();
|
||||
vmsize *= page_size; vmrss *= page_size; vmdata *= page_size;
|
||||
vmtext *= page_size; vmlib *= page_size;
|
||||
}
|
||||
@ -918,7 +918,7 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss,
|
||||
MEMORY_WORKING_SET_LIST *mwsl;
|
||||
ULONG n = 0x1000, length;
|
||||
PULONG p = (PULONG) malloc (sizeof (ULONG) * n);
|
||||
unsigned page_size = getpagesize ();
|
||||
unsigned page_size = getsystempagesize ();
|
||||
hProcess = OpenProcess (PROCESS_QUERY_INFORMATION,
|
||||
FALSE, dwProcessId);
|
||||
if (hProcess == NULL)
|
||||
|
@ -31,6 +31,11 @@ extern "C" {
|
||||
#define MAP_ANONYMOUS 0x20
|
||||
#define MAP_ANON MAP_ANONYMOUS
|
||||
/* Non-standard flag */
|
||||
#if 0 /* Not yet implemented */
|
||||
#define MAP_NORESERVE 0x4000 /* Don't reserve swap space for this mapping.
|
||||
Page protection must be set explicitely
|
||||
to access page. */
|
||||
#endif
|
||||
#define MAP_AUTOGROW 0x8000 /* Grow underlying object to mapping size.
|
||||
File must be opened for writing. */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,7 +24,7 @@
|
||||
#define WSLE_PAGE_SHARE_COUNT_MASK 0x0E0
|
||||
#define WSLE_PAGE_SHAREABLE 0x100
|
||||
|
||||
#define AT_ROUND_TO_PAGE 0x40000000
|
||||
#define AT_EXTENDABLE_FILE 0x00002000
|
||||
|
||||
#define LOCK_VM_IN_WSL 1
|
||||
#define LOCK_VM_IN_RAM 2
|
||||
@ -479,6 +479,8 @@ extern "C"
|
||||
NTSTATUS NTAPI NtCreateFile (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
|
||||
PIO_STATUS_BLOCK, PLARGE_INTEGER, ULONG, ULONG,
|
||||
ULONG, ULONG, PVOID, ULONG);
|
||||
NTSTATUS NTAPI NtCreateSection (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
|
||||
PLARGE_INTEGER, ULONG, ULONG, HANDLE);
|
||||
NTSTATUS NTAPI NtCreateToken (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
|
||||
TOKEN_TYPE, PLUID, PLARGE_INTEGER, PTOKEN_USER,
|
||||
PTOKEN_GROUPS, PTOKEN_PRIVILEGES, PTOKEN_OWNER,
|
||||
|
@ -1380,15 +1380,15 @@ getpagesize ()
|
||||
{
|
||||
if (!system_info.dwPageSize)
|
||||
GetSystemInfo (&system_info);
|
||||
return (int) system_info.dwPageSize;
|
||||
return (size_t) system_info.dwAllocationGranularity;
|
||||
}
|
||||
|
||||
size_t
|
||||
getshmlba ()
|
||||
getsystempagesize ()
|
||||
{
|
||||
if (!system_info.dwAllocationGranularity)
|
||||
GetSystemInfo (&system_info);
|
||||
return system_info.dwAllocationGranularity;
|
||||
return (size_t) system_info.dwPageSize;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -37,6 +37,7 @@ static NO_COPY wincaps wincap_unknown = {
|
||||
has_working_copy_on_write:false,
|
||||
share_mmaps_only_by_name:false,
|
||||
virtual_protect_works_on_shared_pages:false,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:false,
|
||||
can_open_directories:false,
|
||||
has_move_file_ex:false,
|
||||
@ -90,6 +91,7 @@ static NO_COPY wincaps wincap_95 = {
|
||||
has_working_copy_on_write:false,
|
||||
share_mmaps_only_by_name:true,
|
||||
virtual_protect_works_on_shared_pages:false,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:false,
|
||||
can_open_directories:false,
|
||||
has_move_file_ex:false,
|
||||
@ -143,6 +145,7 @@ static NO_COPY wincaps wincap_95osr2 = {
|
||||
has_working_copy_on_write:false,
|
||||
share_mmaps_only_by_name:true,
|
||||
virtual_protect_works_on_shared_pages:false,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:false,
|
||||
can_open_directories:false,
|
||||
has_move_file_ex:false,
|
||||
@ -196,6 +199,7 @@ static NO_COPY wincaps wincap_98 = {
|
||||
has_working_copy_on_write:false,
|
||||
share_mmaps_only_by_name:true,
|
||||
virtual_protect_works_on_shared_pages:false,
|
||||
has_mmap_alignment_bug:true,
|
||||
has_hard_links:false,
|
||||
can_open_directories:false,
|
||||
has_move_file_ex:false,
|
||||
@ -249,6 +253,7 @@ static NO_COPY wincaps wincap_98se = {
|
||||
has_working_copy_on_write:false,
|
||||
share_mmaps_only_by_name:true,
|
||||
virtual_protect_works_on_shared_pages:false,
|
||||
has_mmap_alignment_bug:true,
|
||||
has_hard_links:false,
|
||||
can_open_directories:false,
|
||||
has_move_file_ex:false,
|
||||
@ -302,6 +307,7 @@ static NO_COPY wincaps wincap_me = {
|
||||
has_working_copy_on_write:false,
|
||||
share_mmaps_only_by_name:true,
|
||||
virtual_protect_works_on_shared_pages:false,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:false,
|
||||
can_open_directories:false,
|
||||
has_move_file_ex:false,
|
||||
@ -355,6 +361,7 @@ static NO_COPY wincaps wincap_nt3 = {
|
||||
has_working_copy_on_write:true,
|
||||
share_mmaps_only_by_name:false,
|
||||
virtual_protect_works_on_shared_pages:true,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:true,
|
||||
can_open_directories:true,
|
||||
has_move_file_ex:true,
|
||||
@ -408,6 +415,7 @@ static NO_COPY wincaps wincap_nt4 = {
|
||||
has_working_copy_on_write:true,
|
||||
share_mmaps_only_by_name:false,
|
||||
virtual_protect_works_on_shared_pages:true,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:true,
|
||||
can_open_directories:true,
|
||||
has_move_file_ex:true,
|
||||
@ -461,6 +469,7 @@ static NO_COPY wincaps wincap_nt4sp4 = {
|
||||
has_working_copy_on_write:true,
|
||||
share_mmaps_only_by_name:false,
|
||||
virtual_protect_works_on_shared_pages:true,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:true,
|
||||
can_open_directories:true,
|
||||
has_move_file_ex:true,
|
||||
@ -514,6 +523,7 @@ static NO_COPY wincaps wincap_2000 = {
|
||||
has_working_copy_on_write:true,
|
||||
share_mmaps_only_by_name:false,
|
||||
virtual_protect_works_on_shared_pages:true,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:true,
|
||||
can_open_directories:true,
|
||||
has_move_file_ex:true,
|
||||
@ -567,6 +577,7 @@ static NO_COPY wincaps wincap_xp = {
|
||||
has_working_copy_on_write:true,
|
||||
share_mmaps_only_by_name:false,
|
||||
virtual_protect_works_on_shared_pages:true,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:true,
|
||||
can_open_directories:true,
|
||||
has_move_file_ex:true,
|
||||
@ -620,6 +631,7 @@ static NO_COPY wincaps wincap_2003 = {
|
||||
has_working_copy_on_write:true,
|
||||
share_mmaps_only_by_name:false,
|
||||
virtual_protect_works_on_shared_pages:true,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:true,
|
||||
can_open_directories:true,
|
||||
has_move_file_ex:true,
|
||||
@ -673,6 +685,7 @@ static NO_COPY wincaps wincap_vista = {
|
||||
has_working_copy_on_write:true,
|
||||
share_mmaps_only_by_name:false,
|
||||
virtual_protect_works_on_shared_pages:true,
|
||||
has_mmap_alignment_bug:false,
|
||||
has_hard_links:true,
|
||||
can_open_directories:true,
|
||||
has_move_file_ex:true,
|
||||
|
@ -38,6 +38,7 @@ struct wincaps
|
||||
unsigned has_working_copy_on_write : 1;
|
||||
unsigned share_mmaps_only_by_name : 1;
|
||||
unsigned virtual_protect_works_on_shared_pages : 1;
|
||||
unsigned has_mmap_alignment_bug : 1;
|
||||
unsigned has_hard_links : 1;
|
||||
unsigned can_open_directories : 1;
|
||||
unsigned has_move_file_ex : 1;
|
||||
@ -105,6 +106,7 @@ public:
|
||||
bool IMPLEMENT (has_working_copy_on_write)
|
||||
bool IMPLEMENT (share_mmaps_only_by_name)
|
||||
bool IMPLEMENT (virtual_protect_works_on_shared_pages)
|
||||
bool IMPLEMENT (has_mmap_alignment_bug)
|
||||
bool IMPLEMENT (has_hard_links)
|
||||
bool IMPLEMENT (can_open_directories)
|
||||
bool IMPLEMENT (has_move_file_ex)
|
||||
|
@ -296,7 +296,11 @@ int fcntl_worker (int fd, int cmd, void *arg);
|
||||
extern "C" int low_priority_sleep (DWORD) __attribute__ ((regparm (1)));
|
||||
#define SLEEP_0_STAY_LOW INFINITE
|
||||
|
||||
size_t getshmlba ();
|
||||
/* Returns the real page size, not the allocation size. */
|
||||
size_t getsystempagesize ();
|
||||
|
||||
/* Init mmap function pointers. */
|
||||
void mmap_init ();
|
||||
|
||||
int winprio_to_nice (DWORD) __attribute__ ((regparm (1)));
|
||||
DWORD nice_to_winprio (int &) __attribute__ ((regparm (1)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user