public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: console: Revive Win7 compatibility.
Date: Fri, 20 Sep 2019 02:19:00 -0000	[thread overview]
Message-ID: <20190920021908.81667.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=1a44ad03e0f723e9479d090c43444bce2798a35d

commit 1a44ad03e0f723e9479d090c43444bce2798a35d
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Thu Sep 19 05:49:55 2019 +0900

    Cygwin: console: Revive Win7 compatibility.
    
    - The commit fca4cda7a420d7b15ac217d008527e029d05758e broke Win7
      compatibility. This patch fixes the issue.

Diff:
---
 winsup/cygwin/fhandler.h          | 6 ++++++
 winsup/cygwin/fhandler_console.cc | 6 ------
 winsup/cygwin/select.cc           | 1 -
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 4efb6a4..d5aa573 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -43,6 +43,12 @@ details. */
 
 #define O_TMPFILE_FILE_ATTRS (FILE_ATTRIBUTE_TEMPORARY | FILE_ATTRIBUTE_HIDDEN)
 
+/* Buffer size for ReadConsoleInput() and PeekConsoleInput(). */
+/* Per MSDN, max size of buffer required is below 64K. */
+/* (65536 / sizeof (INPUT_RECORD)) is 3276, however,
+   ERROR_NOT_ENOUGH_MEMORY occurs in win7 if this value is used. */
+#define INREC_SIZE 2048
+
 extern const char *windows_device_names[];
 extern struct __cygwin_perfile *perfile_table;
 #define __fmode (*(user_data->fmode_ptr))
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 709b825..86c39db 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -499,9 +499,6 @@ fhandler_console::process_input_message (void)
 
   termios *ti = &(get_ttyp ()->ti);
 
-	  /* Per MSDN, max size of buffer required is below 64K. */
-#define	  INREC_SIZE	(65536 / sizeof (INPUT_RECORD))
-
   fhandler_console::input_states stat = input_processing;
   DWORD total_read, i;
   INPUT_RECORD input_rec[INREC_SIZE];
@@ -1165,9 +1162,6 @@ fhandler_console::ioctl (unsigned int cmd, void *arg)
 	return -1;
       case FIONREAD:
 	{
-	  /* Per MSDN, max size of buffer required is below 64K. */
-#define	  INREC_SIZE	(65536 / sizeof (INPUT_RECORD))
-
 	  DWORD n;
 	  int ret = 0;
 	  INPUT_RECORD inp[INREC_SIZE];
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index ed8c98d..e701442 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -1209,7 +1209,6 @@ peek_pty_slave (select_record *s, bool from_select)
 	{
 	  if (ptys->is_line_input ())
 	    {
-#define INREC_SIZE (65536 / sizeof (INPUT_RECORD))
 	      INPUT_RECORD inp[INREC_SIZE];
 	      DWORD n;
 	      PeekConsoleInput (ptys->get_handle (), inp, INREC_SIZE, &n);


                 reply	other threads:[~2019-09-20  2:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190920021908.81667.qmail@sourceware.org \
    --to=kbrown@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).