OSDN Git Service

* fhandler_console.cc (fhandler_console::read): Drop 9x specific
authorcorinna <corinna>
Thu, 22 Feb 2007 17:35:13 +0000 (17:35 +0000)
committercorinna <corinna>
Thu, 22 Feb 2007 17:35:13 +0000 (17:35 +0000)
handling of AltGr key.
* mmap.cc: Take NT for granted throughout.
* wincap.cc: Remove map_view_of_file_ex_sucks, altgr_is_ctrl_alt,
has_working_copy_on_write, share_mmaps_only_by_name,
virtual_protect_works_on_shared_pages, has_mmap_alignment_bug and
has_working_virtual_lock throughout.
* wincap.h: Ditto.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_console.cc
winsup/cygwin/mmap.cc
winsup/cygwin/wincap.cc
winsup/cygwin/wincap.h

index 3930961..65ddb7b 100644 (file)
@@ -1,5 +1,16 @@
 2007-02-22  Corinna Vinschen  <corinna@vinschen.de>
 
+       * fhandler_console.cc (fhandler_console::read): Drop 9x specific
+       handling of AltGr key.
+       * mmap.cc: Take NT for granted throughout.
+       * wincap.cc: Remove map_view_of_file_ex_sucks, altgr_is_ctrl_alt,
+       has_working_copy_on_write, share_mmaps_only_by_name,
+       virtual_protect_works_on_shared_pages, has_mmap_alignment_bug and
+       has_working_virtual_lock throughout.
+       * wincap.h: Ditto.
+
+2007-02-22  Corinna Vinschen  <corinna@vinschen.de>
+
        * fhandler.cc (fhandler_base::set_no_inheritance): Always use
        SetHandleInformation.
        * fhandler_disk_file.cc (fhandler_disk_file::lock): Always use
index 13501dd..4bd04fb 100644 (file)
@@ -385,17 +385,9 @@ fhandler_console::read (void *pv, size_t& buflen)
                 part is to distinguish whether the right Alt key should be
                 recognized as Alt, or as AltGr. */
              bool meta;
-             if (wincap.altgr_is_ctrl_alt ())
-               /* WinNT: AltGr is reported as Ctrl+Alt, and Ctrl+Alt is
-                  treated just like AltGr.  However, if Ctrl+Alt+key generates
-                  an ASCII control character, interpret is as META. */
-               meta = (control_key_state & ALT_PRESSED) != 0
-                      && ((control_key_state & CTRL_PRESSED) == 0
-                          || ((signed char) ich >= 0 && ich <= 0x1f || ich == 0x7f));
-             else
-               /* Win9x: there's no way to distinguish Alt from AltGr, so rely
-                  on dev_state->meta_mask heuristic (see fhandler_console constructor). */
-               meta = (control_key_state & dev_state->meta_mask) != 0;
+             meta = (control_key_state & ALT_PRESSED) != 0
+                    && ((control_key_state & CTRL_PRESSED) == 0
+                        || ((signed char) ich >= 0 && ich <= 0x1f || ich == 0x7f));
              if (!meta)
                toadd = tmp + 1;
              else if (dev_state->metabit)
index df6ff58..7e44317 100644 (file)
@@ -105,9 +105,7 @@ gen_create_protect (DWORD openflags, int flags)
   else if (openflags & GENERIC_WRITE)
     ret = PAGE_READWRITE;
 
-  /* Ignore EXECUTE permission on 9x. */
-  if ((openflags & GENERIC_EXECUTE)
-      && wincap.virtual_protect_works_on_shared_pages ())
+  if (openflags & GENERIC_EXECUTE)
     ret <<= 4;
 
   return ret;
@@ -130,9 +128,7 @@ gen_protect (int prot, int flags)
   else if (prot & PROT_READ)
     ret = PAGE_READONLY;
 
-  /* Ignore EXECUTE permission on 9x. */
-  if ((prot & PROT_EXEC)
-      && wincap.virtual_protect_works_on_shared_pages ())
+  if (prot & PROT_EXEC)
     ret <<= 4;
 
   return ret;
@@ -833,7 +829,6 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
   struct __stat64 st;
 
   DWORD pagesize = getpagesize ();
-  DWORD checkpagesize;
 
   fh_anonymous.set_io_handle (INVALID_HANDLE_VALUE);
   fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE);
@@ -841,36 +836,18 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
 
   SetResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
 
-  /* EINVAL error conditions.  Note that the addr%pagesize test is deferred
-     to workaround a serious alignment problem in Windows 98.  */
+  /* EINVAL error conditions. */
   if (off % pagesize
       || ((prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)))
       || ((flags & MAP_TYPE) != MAP_SHARED
          && (flags & MAP_TYPE) != MAP_PRIVATE)
-#if 0
       || (fixed (flags) && ((uintptr_t) addr % pagesize))
-#endif
       || !len)
     {
       set_errno (EINVAL);
       goto out;
     }
 
-  /* There's a serious alignment problem in Windows 98.  MapViewOfFile
-     sometimes returns addresses which are page aligned instead of
-     granularity aligned.  OTOH, it's not possible to force such an
-     address using MapViewOfFileEx.  So what we do here to let it work
-     at least most of the time is, allow 4K aligned addresses in 98,
-     to enable remapping of formerly mapped pages.  If no matching
-     free pages exist, check addr again, this time for the real alignment. */
-  checkpagesize = wincap.has_mmap_alignment_bug () ?
-                 getsystempagesize () : pagesize;
-  if (fixed (flags) && ((uintptr_t) addr % checkpagesize))
-    {
-      set_errno (EINVAL);
-      goto out;
-    }
-
   if (!anonymous (flags) && fd != -1)
     {
       /* Ensure that fd is open */
@@ -956,19 +933,12 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
          goto go_ahead;
        }
       fsiz -= off;
-      /* On NT systems we're creating the pages beyond EOF as reserved,
-        anonymous pages.  That's not possible on 9x for two reasons.
-        It neither allows to create reserved pages in the shared memory
-        area, nor does it allow to create page aligend mappings (in
-        contrast to granularity aligned mappings).
-
+      /* We're creating the pages beyond EOF as reserved, anonymous pages.
         Note that this isn't done in WOW64 environments since apparently
         WOW64 does not support the AT_ROUND_TO_PAGE flag which is required
         to get this right.  Too bad. */
-      if (wincap.virtual_protect_works_on_shared_pages ()
-         && !wincap.is_wow64 ()
-         && ((len > fsiz && !autogrow (flags))
-             || len < pagesize))
+      if (!wincap.is_wow64 ()
+         && ((len > fsiz && !autogrow (flags)) || len < pagesize))
        orig_len = len;
       if (len > fsiz)
        {
@@ -1018,14 +988,6 @@ go_ahead:
        }
     }
 
-  /* Deferred alignment test, see above. */
-  if (wincap.has_mmap_alignment_bug ()
-      && fixed (flags) && ((uintptr_t) addr % pagesize))
-    {
-      set_errno (EINVAL);
-      goto out;
-    }
-
   if (orig_len)
     {
       /* If the requested length is bigger than the file size, we try to
@@ -1144,9 +1106,7 @@ munmap (void *addr, size_t len)
       set_errno (EINVAL);
       return -1;
     }
-  /* See comment in mmap64 for a description. */
-  size_t pagesize = wincap.has_mmap_alignment_bug () ?
-                   getsystempagesize () : getpagesize ();
+  size_t pagesize = getpagesize ();
   if (((uintptr_t) addr % pagesize) || !len)
     {
       set_errno (EINVAL);
@@ -1210,10 +1170,7 @@ msync (void *addr, size_t len, int flags)
 
   SetResourceLock (LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
 
-  /* See comment in mmap64 for a description. */
-  size_t pagesize = wincap.has_mmap_alignment_bug () ?
-                   getsystempagesize () : getpagesize ();
-  if (((uintptr_t) addr % pagesize)
+  if (((uintptr_t) addr % getpagesize ())
       || (flags & ~(MS_ASYNC | MS_SYNC | MS_INVALIDATE))
       || (flags & (MS_ASYNC | MS_SYNC) == (MS_ASYNC | MS_SYNC)))
     {
@@ -1221,7 +1178,7 @@ msync (void *addr, size_t len, int flags)
       goto out;
     }
 #if 0 /* If I only knew why I did that... */
-  len = roundup2 (len, pagesize);
+  len = roundup2 (len, getpagesize ());
 #endif
 
   /* Iterate through the map, looking for the mmapped area.
@@ -1274,8 +1231,7 @@ mprotect (void *addr, size_t len, int prot)
   syscall_printf ("mprotect (addr: %p, len %u, prot %x)", addr, len, prot);
 
   /* See comment in mmap64 for a description. */
-  size_t pagesize = wincap.has_mmap_alignment_bug () ?
-                   getsystempagesize () : getpagesize ();
+  size_t pagesize = getpagesize ();
   if ((uintptr_t) addr % pagesize)
     {
       set_errno (EINVAL);
@@ -1361,9 +1317,6 @@ out:
 extern "C" int
 mlock (const void *addr, size_t len)
 {
-  if (!wincap.has_working_virtual_lock ())
-    return 0;
-
   int ret = -1;
 
   /* Instead of using VirtualLock, which does not guarantee that the pages
@@ -1429,9 +1382,6 @@ mlock (const void *addr, size_t len)
 extern "C" int
 munlock (const void *addr, size_t len)
 {
-  if (!wincap.has_working_virtual_lock ())
-    return 0;
-
   int ret = -1;
 
   push_thread_privilege (SE_LOCK_MEMORY_PRIV, true);
index 8c9034f..0b481d3 100644 (file)
@@ -20,13 +20,7 @@ static NO_COPY wincaps wincap_unknown = {
   has_security:true,
   has_security_descriptor_control:false,
   has_ip_helper_lib:false,
-  map_view_of_file_ex_sucks:false,
-  altgr_is_ctrl_alt:true,
   has_physical_mem_access:true,
-  has_working_copy_on_write:true,
-  share_mmaps_only_by_name:false,
-  virtual_protect_works_on_shared_pages:true,
-  has_mmap_alignment_bug:false,
   has_hard_links:true,
   can_open_directories:true,
   has_move_file_ex:true,
@@ -51,7 +45,6 @@ static NO_COPY wincaps wincap_unknown = {
   detect_win16_exe:false,
   has_null_console_handler_routine:true,
   has_disk_ex_ioctls:false,
-  has_working_virtual_lock:true,
   has_disabled_user_tos_setting:false,
   has_fileid_dirinfo:false,
   has_exclusiveaddruse:false,
@@ -73,13 +66,7 @@ static NO_COPY wincaps wincap_nt4 = {
   has_security:true,
   has_security_descriptor_control:false,
   has_ip_helper_lib:false,
-  map_view_of_file_ex_sucks:false,
-  altgr_is_ctrl_alt:true,
   has_physical_mem_access:true,
-  has_working_copy_on_write:true,
-  share_mmaps_only_by_name:false,
-  virtual_protect_works_on_shared_pages:true,
-  has_mmap_alignment_bug:false,
   has_hard_links:true,
   can_open_directories:true,
   has_move_file_ex:true,
@@ -104,7 +91,6 @@ static NO_COPY wincaps wincap_nt4 = {
   detect_win16_exe:false,
   has_null_console_handler_routine:true,
   has_disk_ex_ioctls:false,
-  has_working_virtual_lock:true,
   has_disabled_user_tos_setting:false,
   has_fileid_dirinfo:false,
   has_exclusiveaddruse:false,
@@ -126,13 +112,7 @@ static NO_COPY wincaps wincap_nt4sp4 = {
   has_security:true,
   has_security_descriptor_control:false,
   has_ip_helper_lib:true,
-  map_view_of_file_ex_sucks:false,
-  altgr_is_ctrl_alt:true,
   has_physical_mem_access:true,
-  has_working_copy_on_write:true,
-  share_mmaps_only_by_name:false,
-  virtual_protect_works_on_shared_pages:true,
-  has_mmap_alignment_bug:false,
   has_hard_links:true,
   can_open_directories:true,
   has_move_file_ex:true,
@@ -157,7 +137,6 @@ static NO_COPY wincaps wincap_nt4sp4 = {
   detect_win16_exe:false,
   has_null_console_handler_routine:true,
   has_disk_ex_ioctls:false,
-  has_working_virtual_lock:true,
   has_disabled_user_tos_setting:false,
   has_fileid_dirinfo:false,
   has_exclusiveaddruse:true,
@@ -179,13 +158,7 @@ static NO_COPY wincaps wincap_2000 = {
   has_security:true,
   has_security_descriptor_control:true,
   has_ip_helper_lib:true,
-  map_view_of_file_ex_sucks:false,
-  altgr_is_ctrl_alt:true,
   has_physical_mem_access:true,
-  has_working_copy_on_write:true,
-  share_mmaps_only_by_name:false,
-  virtual_protect_works_on_shared_pages:true,
-  has_mmap_alignment_bug:false,
   has_hard_links:true,
   can_open_directories:true,
   has_move_file_ex:true,
@@ -210,7 +183,6 @@ static NO_COPY wincaps wincap_2000 = {
   detect_win16_exe:false,
   has_null_console_handler_routine:true,
   has_disk_ex_ioctls:false,
-  has_working_virtual_lock:true,
   has_disabled_user_tos_setting:true,
   has_fileid_dirinfo:true,
   has_exclusiveaddruse:true,
@@ -232,13 +204,7 @@ static NO_COPY wincaps wincap_xp = {
   has_security:true,
   has_security_descriptor_control:true,
   has_ip_helper_lib:true,
-  map_view_of_file_ex_sucks:false,
-  altgr_is_ctrl_alt:true,
   has_physical_mem_access:true,
-  has_working_copy_on_write:true,
-  share_mmaps_only_by_name:false,
-  virtual_protect_works_on_shared_pages:true,
-  has_mmap_alignment_bug:false,
   has_hard_links:true,
   can_open_directories:true,
   has_move_file_ex:true,
@@ -263,7 +229,6 @@ static NO_COPY wincaps wincap_xp = {
   detect_win16_exe:false,
   has_null_console_handler_routine:true,
   has_disk_ex_ioctls:true,
-  has_working_virtual_lock:true,
   has_disabled_user_tos_setting:true,
   has_fileid_dirinfo:true,
   has_exclusiveaddruse:true,
@@ -285,13 +250,7 @@ static NO_COPY wincaps wincap_2003 = {
   has_security:true,
   has_security_descriptor_control:true,
   has_ip_helper_lib:true,
-  map_view_of_file_ex_sucks:false,
-  altgr_is_ctrl_alt:true,
   has_physical_mem_access:false,
-  has_working_copy_on_write:true,
-  share_mmaps_only_by_name:false,
-  virtual_protect_works_on_shared_pages:true,
-  has_mmap_alignment_bug:false,
   has_hard_links:true,
   can_open_directories:true,
   has_move_file_ex:true,
@@ -316,7 +275,6 @@ static NO_COPY wincaps wincap_2003 = {
   detect_win16_exe:false,
   has_null_console_handler_routine:true,
   has_disk_ex_ioctls:true,
-  has_working_virtual_lock:true,
   has_disabled_user_tos_setting:true,
   has_fileid_dirinfo:true,
   has_exclusiveaddruse:true,
@@ -338,13 +296,7 @@ static NO_COPY wincaps wincap_vista = {
   has_security:true,
   has_security_descriptor_control:true,
   has_ip_helper_lib:true,
-  map_view_of_file_ex_sucks:false,
-  altgr_is_ctrl_alt:true,
   has_physical_mem_access:false,
-  has_working_copy_on_write:true,
-  share_mmaps_only_by_name:false,
-  virtual_protect_works_on_shared_pages:true,
-  has_mmap_alignment_bug:false,
   has_hard_links:true,
   can_open_directories:true,
   has_move_file_ex:true,
@@ -369,7 +321,6 @@ static NO_COPY wincaps wincap_vista = {
   detect_win16_exe:false,
   has_null_console_handler_routine:true,
   has_disk_ex_ioctls:true,
-  has_working_virtual_lock:true,
   has_disabled_user_tos_setting:true,
   has_fileid_dirinfo:true,
   has_exclusiveaddruse:true,
index 7eb49c0..a3198cd 100644 (file)
@@ -20,13 +20,7 @@ struct wincaps
   unsigned has_security                                 : 1;
   unsigned has_security_descriptor_control              : 1;
   unsigned has_ip_helper_lib                            : 1;
-  unsigned map_view_of_file_ex_sucks                    : 1;
-  unsigned altgr_is_ctrl_alt                            : 1;
   unsigned has_physical_mem_access                      : 1;
-  unsigned has_working_copy_on_write                    : 1;
-  unsigned share_mmaps_only_by_name                     : 1;
-  unsigned virtual_protect_works_on_shared_pages        : 1;
-  unsigned has_mmap_alignment_bug                      : 1;
   unsigned has_hard_links                               : 1;
   unsigned can_open_directories                         : 1;
   unsigned has_move_file_ex                             : 1;
@@ -51,7 +45,6 @@ struct wincaps
   unsigned detect_win16_exe                            : 1;
   unsigned has_null_console_handler_routine            : 1;
   unsigned has_disk_ex_ioctls                          : 1;
-  unsigned has_working_virtual_lock                    : 1;
   unsigned has_disabled_user_tos_setting               : 1;
   unsigned has_fileid_dirinfo                          : 1;
   unsigned has_exclusiveaddruse                                : 1;
@@ -89,13 +82,7 @@ public:
   bool  IMPLEMENT (has_security)
   bool  IMPLEMENT (has_security_descriptor_control)
   bool  IMPLEMENT (has_ip_helper_lib)
-  bool  IMPLEMENT (map_view_of_file_ex_sucks)
-  bool  IMPLEMENT (altgr_is_ctrl_alt)
   bool  IMPLEMENT (has_physical_mem_access)
-  bool  IMPLEMENT (has_working_copy_on_write)
-  bool  IMPLEMENT (share_mmaps_only_by_name)
-  bool  IMPLEMENT (virtual_protect_works_on_shared_pages)
-  bool IMPLEMENT (has_mmap_alignment_bug)
   bool  IMPLEMENT (has_hard_links)
   bool  IMPLEMENT (can_open_directories)
   bool  IMPLEMENT (has_move_file_ex)
@@ -120,7 +107,6 @@ public:
   bool IMPLEMENT (detect_win16_exe)
   bool IMPLEMENT (has_null_console_handler_routine)
   bool IMPLEMENT (has_disk_ex_ioctls)
-  bool IMPLEMENT (has_working_virtual_lock)
   bool IMPLEMENT (has_disabled_user_tos_setting)
   bool IMPLEMENT (has_fileid_dirinfo)
   bool IMPLEMENT (has_exclusiveaddruse)