OSDN Git Service

* mmap.cc (mmap_record::alloc_page_map): Mark pages as allocated even
authorcorinna <corinna>
Fri, 16 Jul 2004 14:32:03 +0000 (14:32 +0000)
committercorinna <corinna>
Fri, 16 Jul 2004 14:32:03 +0000 (14:32 +0000)
on Windows 9x, FWIW.

winsup/cygwin/ChangeLog
winsup/cygwin/mmap.cc

index c217329..4064114 100644 (file)
@@ -1,5 +1,10 @@
 2004-07-15  Corinna Vinschen  <corinna@vinschen.de>
 
+       * mmap.cc (mmap_record::alloc_page_map): Mark pages as allocated even
+       on Windows 9x, FWIW.
+
+2004-07-15  Corinna Vinschen  <corinna@vinschen.de>
+
        * mmap.cc (mprotect): When MAP_WRITE protection is requested, use
        READWRITE or WRITECOPY protection, whatever has been used when the
        page has been allocated initially.
index 1661148..ebca63d 100644 (file)
@@ -168,26 +168,29 @@ mmap_record::alloc_page_map (_off64_t off, DWORD len)
                                       sizeof (DWORD))))
     return false;
 
+  off -= offset_;
+  len = PAGE_CNT (len);
+
   if (wincap.virtual_protect_works_on_shared_pages ())
     {
       DWORD old_prot;
+      DWORD vlen = len * getpagesize ();
 
-      off -= offset_;
-      len = PAGE_CNT (len) * getpagesize ();
       if (off > 0 &&
          !VirtualProtect (base_address_, off, PAGE_NOACCESS, &old_prot))
        syscall_printf ("VirtualProtect(%x,%D) failed: %E", base_address_, off);
-      if (off + len < size_to_map_
-         && !VirtualProtect (base_address_ + off + len,
-                             size_to_map_ - len - off,
+      if (off + vlen < size_to_map_
+         && !VirtualProtect (base_address_ + off + vlen,
+                             size_to_map_ - vlen - off,
                              PAGE_NOACCESS, &old_prot))
        syscall_printf ("VirtualProtect(%x,%D) failed: %E",
-                       base_address_ + off + len, size_to_map_ - len - off);
-      off /= getpagesize ();
-      len /= getpagesize ();
-      while (len-- > 0)
-       MAP_SET (off + len);
+                       base_address_ + off + vlen, size_to_map_ - vlen - off);
     }
+
+  off /= getpagesize ();
+
+  while (len-- > 0)
+    MAP_SET (off + len);
   return true;
 }