aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-01-10 09:30:38 +0000
committerCorinna Vinschen <corinna@vinschen.de>2007-01-10 09:30:38 +0000
commit3452cdd3c52a6aa6b0ead88e4d41b81b1b2e844b (patch)
tree1f8bc9f9eb3b79e91dc7d40bf744066a4e0a5a9e
parentac924d61de93263af5c6c9c5725488cef8dbf62d (diff)
downloadnewlib-3452cdd3c52a6aa6b0ead88e4d41b81b1b2e844b.zip
newlib-3452cdd3c52a6aa6b0ead88e4d41b81b1b2e844b.tar.gz
newlib-3452cdd3c52a6aa6b0ead88e4d41b81b1b2e844b.tar.bz2
* mmap.cc (mmap64): Pre-Reserve space for the whole mapping to get a
useful, valid address before the actual mappings take place. Fix typo in comment.
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/mmap.cc26
2 files changed, 31 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index d34ab0e..b0b5944 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,11 @@
2007-01-10 Corinna Vinschen <corinna@vinschen.de>
+ * mmap.cc (mmap64): Pre-Reserve space for the whole mapping to get a
+ useful, valid address before the actual mappings take place.
+ Fix typo in comment.
+
+2007-01-10 Corinna Vinschen <corinna@vinschen.de>
+
* syscalls.cc (sync): Use b_drive for B: drive (Thanks to Howard Chu).
2007-01-09 Corinna Vinschen <corinna@vinschen.de>
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 14a09b5..76524e0 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -1217,6 +1217,28 @@ go_ahead:
goto out;
}
+ if (orig_len)
+ {
+ /* If the requested length is bigger than the file size, we try to
+ allocate an area of the full size first. This area is immediately
+ deallocated and the address we got is used as base address for the
+ subsequent real mappings. This ensures that we have enough space
+ for the whole thing. */
+ orig_len = roundup2 (orig_len, pagesize);
+ addr = VirtualAlloc (addr, orig_len, MEM_TOP_DOWN | MEM_RESERVE,
+ PAGE_READWRITE);
+ if (!addr)
+ {
+ __seterrno ();
+ goto out;
+ }
+ if (!VirtualFree (addr, 0, MEM_RELEASE))
+ {
+ __seterrno ();
+ goto out;
+ }
+ }
+
base = mmap_worker (fh, (caddr_t) addr, len, prot, flags, fd, off);
if (!base)
goto out;
@@ -1225,7 +1247,7 @@ go_ahead:
{
/* If the requested length is bigger than the file size, the
remainder is created as anonymous mapping. Actually two
- mappings are created, first the reminder from the file end to
+ mappings are created, first the remainder from the file end to
the next 64K boundary as accessible pages with the same
protection as the file's pages, then as much pages as necessary
to accomodate the requested length, but as reserved pages which
@@ -1233,7 +1255,9 @@ go_ahead:
and page protection on shared pages is only supported by 32 bit NT,
so don't even try on 9x and in WOW64. This is accomplished by not
setting orig_len on 9x and in WOW64 above. */
+#if 0
orig_len = roundup2 (orig_len, pagesize);
+#endif
len = roundup2 (len, getsystempagesize ());
if (orig_len - len)
{