[PATCH] Cygwin: console: Revive Win7 compatibility.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Cygwin: console: Revive Win7 compatibility.

Takashi Yano
- The commit fca4cda7a420d7b15ac217d008527e029d05758e broke Win7
  compatibility. This patch fixes the issue.
---
 winsup/cygwin/fhandler_console.cc | 10 +++++-----
 winsup/cygwin/select.cc           |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 709b8255d..75143f27a 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -499,8 +499,11 @@ 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))
+  /* 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
 
   fhandler_console::input_states stat = input_processing;
   DWORD total_read, i;
@@ -1165,9 +1168,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 ed8c98d1c..8fdce06a4 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -1209,7 +1209,7 @@ peek_pty_slave (select_record *s, bool from_select)
  {
   if (ptys->is_line_input ())
     {
-#define INREC_SIZE (65536 / sizeof (INPUT_RECORD))
+#define INREC_SIZE 2048
       INPUT_RECORD inp[INREC_SIZE];
       DWORD n;
       PeekConsoleInput (ptys->get_handle (), inp, INREC_SIZE, &n);
--
2.21.0

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: console: Revive Win7 compatibility.

Achim Gratz
Takashi Yano writes:
> - The commit fca4cda7a420d7b15ac217d008527e029d05758e broke Win7
>   compatibility. This patch fixes the issue.
> ---
>  winsup/cygwin/fhandler_console.cc | 10 +++++-----
>  winsup/cygwin/select.cc           |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)

It seems like an attractor for future bugs to define the same constant
in two different places.  Would there be a header that could provide the
definition instead?


Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: console: Revive Win7 compatibility.

Takashi Yano
On Wed, 18 Sep 2019 18:21:49 +0200
Achim Gratz wrote:

> Takashi Yano writes:
> > - The commit fca4cda7a420d7b15ac217d008527e029d05758e broke Win7
> >   compatibility. This patch fixes the issue.
> > ---
> >  winsup/cygwin/fhandler_console.cc | 10 +++++-----
> >  winsup/cygwin/select.cc           |  2 +-
> >  2 files changed, 6 insertions(+), 6 deletions(-)
>
> It seems like an attractor for future bugs to define the same constant
> in two different places.  Would there be a header that could provide the
> definition instead?

I agree with you. I will post revised one as v2.

--
Takashi Yano <[hidden email]>