* mmap.cc (MapView9x): Note possible uselessness of retrying.
(MapViewNT): Ditto. (mmap64): Fix pre-reservation to work for non NULL, non MAP_FIXED.
This commit is contained in:
parent
cbe2437b28
commit
9f3e3df961
|
@ -1,3 +1,9 @@
|
||||||
|
2007-01-17 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* mmap.cc (MapView9x): Note possible uselessness of retrying.
|
||||||
|
(MapViewNT): Ditto.
|
||||||
|
(mmap64): Fix pre-reservation to work for non NULL, non MAP_FIXED.
|
||||||
|
|
||||||
2007-01-16 Corinna Vinschen <corinna@vinschen.de>
|
2007-01-16 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* autoload.cc (RtlAnsiStringToUnicodeString): Define.
|
* autoload.cc (RtlAnsiStringToUnicodeString): Define.
|
||||||
|
|
|
@ -328,7 +328,10 @@ MapView9x (HANDLE h, void *addr, size_t len, DWORD openflags,
|
||||||
|
|
||||||
/* Try mapping using the given address first, even if it's NULL.
|
/* Try mapping using the given address first, even if it's NULL.
|
||||||
If it failed, and addr was not NULL and flags is not MAP_FIXED,
|
If it failed, and addr was not NULL and flags is not MAP_FIXED,
|
||||||
try again with NULL address. */
|
try again with NULL address.
|
||||||
|
|
||||||
|
Note: Retrying the mapping might be unnecessary, now that mmap64 checks
|
||||||
|
for a valid memory area first. */
|
||||||
if (!addr)
|
if (!addr)
|
||||||
base = MapViewOfFile (h, access, high, low, len);
|
base = MapViewOfFile (h, access, high, low, len);
|
||||||
else
|
else
|
||||||
|
@ -357,7 +360,10 @@ MapViewNT (HANDLE h, void *addr, size_t len, DWORD openflags,
|
||||||
|
|
||||||
/* Try mapping using the given address first, even if it's NULL.
|
/* Try mapping using the given address first, even if it's NULL.
|
||||||
If it failed, and addr was not NULL and flags is not MAP_FIXED,
|
If it failed, and addr was not NULL and flags is not MAP_FIXED,
|
||||||
try again with NULL address. */
|
try again with NULL address.
|
||||||
|
|
||||||
|
Note: Retrying the mapping might be unnecessary, now that mmap64 checks
|
||||||
|
for a valid memory area first. */
|
||||||
ret = NtMapViewOfSection (h, GetCurrentProcess (), &base, 0, commitsize,
|
ret = NtMapViewOfSection (h, GetCurrentProcess (), &base, 0, commitsize,
|
||||||
&offset, &viewsize, ViewShare, alloc_type, protect);
|
&offset, &viewsize, ViewShare, alloc_type, protect);
|
||||||
if (!NT_SUCCESS (ret) && addr && !fixed (flags))
|
if (!NT_SUCCESS (ret) && addr && !fixed (flags))
|
||||||
|
@ -1225,18 +1231,27 @@ go_ahead:
|
||||||
subsequent real mappings. This ensures that we have enough space
|
subsequent real mappings. This ensures that we have enough space
|
||||||
for the whole thing. */
|
for the whole thing. */
|
||||||
orig_len = roundup2 (orig_len, pagesize);
|
orig_len = roundup2 (orig_len, pagesize);
|
||||||
addr = VirtualAlloc (addr, orig_len, MEM_TOP_DOWN | MEM_RESERVE,
|
PVOID newaddr = VirtualAlloc (addr, orig_len, MEM_TOP_DOWN | MEM_RESERVE,
|
||||||
PAGE_READWRITE);
|
PAGE_READWRITE);
|
||||||
if (!addr)
|
if (!newaddr)
|
||||||
{
|
{
|
||||||
__seterrno ();
|
/* If addr is not NULL, but MAP_FIXED isn't given, allow the OS
|
||||||
goto out;
|
to choose. */
|
||||||
}
|
if (addr && !fixed (flags))
|
||||||
if (!VirtualFree (addr, 0, MEM_RELEASE))
|
newaddr = VirtualAlloc (NULL, orig_len, MEM_TOP_DOWN | MEM_RESERVE,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!newaddr)
|
||||||
|
{
|
||||||
|
__seterrno ();
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!VirtualFree (newaddr, 0, MEM_RELEASE))
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
addr = newaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
base = mmap_worker (fh, (caddr_t) addr, len, prot, flags, fd, off);
|
base = mmap_worker (fh, (caddr_t) addr, len, prot, flags, fd, off);
|
||||||
|
|
Loading…
Reference in New Issue