From 6556178009cd9bd3112c79510361cfed266f6c43 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 3 Jul 2003 20:53:26 +0000 Subject: [PATCH] * mmap.cc (mmap64): Allow MAP_FIXED with pagesize granularity (4K). If a non-zero addr is given, align it to the next lower 64K boundary. (fhandler_disk_file::mmap): If a non-zero address is given, try mapping using the given address first. If it fails and flags is not MAP_FIXED, try again with NULL address. --- winsup/cygwin/ChangeLog | 41 +++++++++++++++++++++++++++++++++++++++++ winsup/cygwin/mmap.cc | 24 +++++++++++++++++------- 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 68954c561..998f89a76 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,44 @@ +2003-07-03 Corinna Vinschen + + * mmap.cc (mmap64): Allow MAP_FIXED with pagesize granularity (4K). + If a non-zero addr is given, align it to the next lower 64K boundary. + (fhandler_disk_file::mmap): If a non-zero address is given, try + mapping using the given address first. If it fails and flags is not + MAP_FIXED, try again with NULL address. + +2003-07-01 Christopher Faylor + + * thread.cc: Remove _MT_SAFE conditional. + +2003-07-01 Christopher Faylor + + * configure.in: Fix --enable-server option. + * configure: Regenerate. + +2003-07-01 Christopher Faylor + + * Makefile.in: Remove cygserver stuff. + * acconfig.h: Add USE_CYGSERVER define. + * config.h.in: Regenerate. + * configure.in: Add --enable-server setting. + * configure: Regenerate. + * fhandler_tty.cc (fhandler_tty_slave::open): Conditionalize + compilation of cygserver stuff. + * fork.cc (fork_child): Ditto. + * shm.cc: Ditto. + * tty.cc (tty::common_init): Ditto. + + * dcrt0.cc: Use bool rather than BOOL for CYGWIN environment variable + definitions. + * environ.cc: Ditto. + * ntea.cc: Ditto. + * security.cc: Ditto. + * security.h: Ditto. + * syscalls.cc (check_posix_perm): Remove externs that were already + declared in a header. + * winsup.h: Ditto. Declare _MT_SAFE here. Delete it someday since + cygwin should always be _MT_SAFE. + 2003-07-01 Christopher Faylor * thread.cc: Remove _MT_SAFE conditional. diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc index 172468038..538ab2058 100644 --- a/winsup/cygwin/mmap.cc +++ b/winsup/cygwin/mmap.cc @@ -438,7 +438,7 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, _off64_t off) if (off % getpagesize () || (!(flags & MAP_SHARED) && !(flags & MAP_PRIVATE)) || ((flags & MAP_SHARED) && (flags & MAP_PRIVATE)) - || ((flags & MAP_FIXED) && ((DWORD)addr % granularity)) + || ((flags & MAP_FIXED) && ((DWORD)addr % getpagesize ())) || !len) { set_errno (EINVAL); @@ -469,8 +469,6 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, _off64_t off) DWORD gran_len = howmany (off + len, granularity) * granularity - gran_off; fhandler_base *fh; - caddr_t base = addr; - HANDLE h; if (fd != -1) { @@ -540,7 +538,13 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, _off64_t off) && (wincap.has_working_copy_on_write () || fd != -1)) access = FILE_MAP_COPY; - h = fh->mmap (&base, gran_len, access, flags, gran_off); + caddr_t base = addr; + /* This shifts the base address to the next lower 64K boundary. + The offset is re-added when evaluating the return value. */ + if (base) + base -= off - gran_off; + + HANDLE h = fh->mmap (&base, gran_len, access, flags, gran_off); if (h == INVALID_HANDLE_VALUE) { @@ -813,9 +817,15 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access, } DWORD high = off >> 32, low = off & 0xffffffff; - void *base = MapViewOfFileEx (h, access, high, low, len, - (flags & MAP_FIXED) ? *addr : NULL); - debug_printf ("%x = MapViewOfFileEx (h:%x, access:%x, 0, off:%D, len:%d, addr:%x)", base, h, access, off, len, (flags & MAP_FIXED) ? *addr : NULL); + void *base = NULL; + /* If a non-zero address is given, try mapping using the given address first. + If it fails and flags is not MAP_FIXED, try again with NULL address. */ + if (addr) + base = MapViewOfFileEx (h, access, high, low, len, *addr); + if (!base && !(flags & MAP_FIXED)) + base = MapViewOfFileEx (h, access, high, low, len, NULL); + debug_printf ("%x = MapViewOfFileEx (h:%x, access:%x, 0, off:%D, " + "len:%d, addr:%x)", base, h, access, off, len, *addr); if (!base || ((flags & MAP_FIXED) && base != *addr)) { if (!base) -- 2.43.5