Commit fdb3d9ae authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ntdll: Use MAP_FIXED_NOREPLACE flag in try_map_free_area() if available.

Avoids actual mapping followed by unmapping back if the memory range is already mapped. Signed-off-by: 's avatarPaul Gofman <pgofman@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 5498ebd8
......@@ -175,6 +175,9 @@ static struct list teb_list = LIST_INIT( teb_list );
#ifndef MAP_TRYFIXED
#define MAP_TRYFIXED 0
#endif
#ifndef MAP_FIXED_NOREPLACE
#define MAP_FIXED_NOREPLACE 0
#endif
#ifdef _WIN64 /* on 64-bit the page protection bytes use a 2-level table */
static const size_t pages_vprot_shift = 20;
......@@ -1005,18 +1008,19 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step,
while (start && base <= start && (char*)start + size <= (char*)end)
{
if ((ptr = wine_anon_mmap( start, size, unix_prot, 0 )) == start)
if ((ptr = wine_anon_mmap( start, size, unix_prot, MAP_FIXED_NOREPLACE )) == start)
return start;
TRACE( "Found free area is already mapped, start %p.\n", start );
if (ptr == (void *)-1)
if (ptr == (void *)-1 && errno != EEXIST)
{
ERR( "wine_anon_mmap() error %s, range %p-%p, unix_prot %#x.\n",
strerror(errno), start, (char *)start + size, unix_prot );
return NULL;
}
munmap( ptr, size );
if (ptr != (void *)-1)
munmap( ptr, size );
if ((step > 0 && (char *)end - (char *)start < step) ||
(step < 0 && (char *)start - (char *)base < -step) ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment