Re: [PATCH 3/6] gendef generates sigfe.s and cygwin.def

2020-10-27 Thread Jon Turney

On 21/10/2020 15:31, Jon Turney wrote:

On 20/10/2020 14:43, Jon Turney wrote:

Express that gendef generates sigfe.s and cygwin.def in a slightly less
nutty way.
---
  winsup/cygwin/Makefile.in | 5 +
  1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index a56a311b8..9d05b17b3 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -785,16 +785,13 @@ $(VERSION_OFILES): version.cc
  Makefile: ${srcdir}/Makefile.in
  /bin/sh ./config.status
-$(DEF_FILE): gendef $(srcdir)/$(TLSOFFSETS_H) $(DIN_FILE)
+$(DEF_FILE) sigfe.s: gendef $(srcdir)/$(TLSOFFSETS_H) $(DIN_FILE)
  $(word 1,$^) --cpu=${target_cpu} --output-def=$@  
--tlsoffsets=$(word 2,$^) $(wordlist 3,99,$^)


Using $@ is wrong if make decides to build sigfe.s first, and $^ will 
contain an unwanted $(DEF_FILE) from the dependency below.


So please try the attached instead.

But maybe I need to do a bit more staring at [1].

[1] 
https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html 



Notwithstanding that, this formulation doesn't actually seem to avoid 
invoking the rule twice in a parallel build, so I think I need to revert 
this.


Re: [PATCH 3/3] Remove recursive configure for cygwin

2020-10-27 Thread Jon Turney

On 22/10/2020 19:57, Jon Turney wrote:


I actually skimped on writing the rules which reconfigure when needed 
when make is run in a subdirectory, as working them out seemed complex 
and a bit redundant, as when I convert to automake, it writes them for you.


I guess I should take another look at that.


Having taken another look, I can't see how to get the necessary 
machinery into config.status, without using automake already.


Re: [PATCH 2/3] Remove ccwrap

2020-10-27 Thread Jon Turney

On 15/10/2020 15:36, Jon Turney wrote:

---
  winsup/Makefile.common   |  4 +--
  winsup/acinclude.m4  | 16 +--
  winsup/c++wrap   |  6 -
  winsup/ccwrap| 51 
  winsup/configure.cygwin  | 10 ---
  winsup/cygserver/Makefile.in |  9 +--
  winsup/cygwin/Makefile.in| 13 +++--
  winsup/cygwin/gentls_offsets |  2 +-
  winsup/utils/Makefile.in | 11 +---
  9 files changed, 16 insertions(+), 106 deletions(-)
  delete mode 100755 winsup/c++wrap
  delete mode 100755 winsup/ccwrap



This breaks running make in a subdirectory, when cross-compiling.

The attached should fix that.

From 27ac737da3347b3918a5e4142ca7aabbcb848e8d Mon Sep 17 00:00:00 2001
From: Jon Turney 
Date: Tue, 27 Oct 2020 15:31:06 +
Subject: [PATCH] Restore setting CC and CXX Makefile variables

b55e3f19 was a bit too aggressive in dropping, rather than just
un-exporting these Makefile variables.  We need to set these to the
configured host compiler if we are cross-compiling, otherwise they
default to the build compiler.

Also export CC to the mkvers.sh script (which requires it since
4eca5e6a).  It's unclear why we can't just cause windres to use the
build 'cpp' as the pre-processor there.
---
 winsup/cygserver/Makefile.in | 3 +++
 winsup/cygwin/Makefile.in| 4 
 winsup/utils/Makefile.in | 3 +++
 3 files changed, 10 insertions(+)

diff --git a/winsup/cygserver/Makefile.in b/winsup/cygserver/Makefile.in
index 7b250dd68..65c402517 100644
--- a/winsup/cygserver/Makefile.in
+++ b/winsup/cygserver/Makefile.in
@@ -11,6 +11,9 @@ target_builddir:=@target_builddir@
 winsup_srcdir:=@winsup_srcdir@
 configure_args=@configure_args@
 
+CC:=@CC@
+CXX:=@CXX@
+
 CFLAGS:=@CFLAGS@
 override CXXFLAGS=@CXXFLAGS@
 override CXXFLAGS+=-MMD -Wimplicit-fallthrough=5 -Werror -D__OUTSIDE_CYGWIN__ 
-DSYSCONFDIR="\"$(sysconfdir)\""
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index dad526b74..f6236d909 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -14,6 +14,9 @@ target_builddir:=@target_builddir@
 winsup_srcdir:=@winsup_srcdir@
 configure_args=@configure_args@
 
+CC:=@CC@
+CXX:=@CXX@
+
 CFLAGS?=@CFLAGS@
 CXXFLAGS?=@CXXFLAGS@
 INCLUDES?=@INCLUDES@
@@ -773,6 +776,7 @@ src_files := $(foreach dir,$(VPATH),$(find_src_files))
 # second, so version.cc is always older than winver.o
 version.cc: mkvers.sh include/cygwin/version.h winver.rc $(src_files)
@echo "Making version.cc and winver.o";\
+   export CC="${CC}";\
/bin/sh ${word 1,$^} ${word 2,$^} ${word 3,$^} $(WINDRES) ${CFLAGS} 
-I${srcdir}/include
 $(VERSION_OFILES): version.cc
 
diff --git a/winsup/utils/Makefile.in b/winsup/utils/Makefile.in
index add29d10f..e21874027 100644
--- a/winsup/utils/Makefile.in
+++ b/winsup/utils/Makefile.in
@@ -11,6 +11,9 @@ target_builddir:=@target_builddir@
 winsup_srcdir:=@winsup_srcdir@
 configure_args=@configure_args@
 
+CC:=@CC@
+CXX:=@CXX@
+
 CFLAGS_COMMON=-Wimplicit-fallthrough=4 -Werror
 CFLAGS:=@CFLAGS@
 CXXFLAGS:=@CXXFLAGS@
-- 
2.29.0



Re: [PATCH] Cygwin: fix return value of sqrtl on negative infinity

2020-10-27 Thread Corinna Vinschen
On Oct 27 10:10, Ken Brown via Cygwin-patches wrote:
> The return value is now -NaN.
> 
> This fixes a bug in the mingw-w64 code that was imported into Cygwin.
> The fix is consistent with Posix and Linux.  It is also consistent
> with the current mingw-w64 code, with one exception: The mingw-w64
> code sets errno to EDOM if the input is -NaN, but this appears to
> differ from Posix and Linux.
> 
> Addresses: https://cygwin.com/pipermail/cygwin/2020-October/246606.html
> ---
>  winsup/cygwin/math/sqrt.def.h | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/winsup/cygwin/math/sqrt.def.h b/winsup/cygwin/math/sqrt.def.h
> index cf8b5cbe6..3d1a00908 100644
> --- a/winsup/cygwin/math/sqrt.def.h
> +++ b/winsup/cygwin/math/sqrt.def.h
> @@ -73,8 +73,11 @@ __FLT_ABI (sqrt) (__FLT_TYPE x)
>if (x_class == FP_ZERO)
>   return __FLT_CST (-0.0);
>  
> +  if (x_class == FP_NAN)
> + return x;
> +
>errno = EDOM;
> -  return x;
> +  return -__FLT_NAN;
>  }
>else if (x_class == FP_ZERO)
>  return __FLT_CST (0.0);
> -- 
> 2.28.0

LGTM


Thanks,
Corinna


[PATCH] Cygwin: fix return value of sqrtl on negative infinity

2020-10-27 Thread Ken Brown via Cygwin-patches
The return value is now -NaN.

This fixes a bug in the mingw-w64 code that was imported into Cygwin.
The fix is consistent with Posix and Linux.  It is also consistent
with the current mingw-w64 code, with one exception: The mingw-w64
code sets errno to EDOM if the input is -NaN, but this appears to
differ from Posix and Linux.

Addresses: https://cygwin.com/pipermail/cygwin/2020-October/246606.html
---
 winsup/cygwin/math/sqrt.def.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/math/sqrt.def.h b/winsup/cygwin/math/sqrt.def.h
index cf8b5cbe6..3d1a00908 100644
--- a/winsup/cygwin/math/sqrt.def.h
+++ b/winsup/cygwin/math/sqrt.def.h
@@ -73,8 +73,11 @@ __FLT_ABI (sqrt) (__FLT_TYPE x)
   if (x_class == FP_ZERO)
return __FLT_CST (-0.0);
 
+  if (x_class == FP_NAN)
+   return x;
+
   errno = EDOM;
-  return x;
+  return -__FLT_NAN;
 }
   else if (x_class == FP_ZERO)
 return __FLT_CST (0.0);
-- 
2.28.0



Re: [PATCH] Cygwin: pty: Disable ResizePseudoConsole() if stdout is redirected.

2020-10-27 Thread Corinna Vinschen
On Oct 27 17:26, Takashi Yano via Cygwin-patches wrote:
> - Calling ResizePseudoConsole() generates some escape sequences.
>   Due to this behaviour, if the output of non-cygwin app is piped
>   to less, screen is sometimes distorted when the screen is resized.
>   With this patch, ResizePseudoConsole() is not called if stdout is
>   redirected.
> ---
>  winsup/cygwin/fhandler_tty.cc | 8 ++--
>  winsup/cygwin/tty.cc  | 1 +
>  winsup/cygwin/tty.h   | 1 +
>  3 files changed, 8 insertions(+), 2 deletions(-)

Pushed.


Thanks,
Corinna


[PATCH] Cygwin: pty: Disable ResizePseudoConsole() if stdout is redirected.

2020-10-27 Thread Takashi Yano via Cygwin-patches
- Calling ResizePseudoConsole() generates some escape sequences.
  Due to this behaviour, if the output of non-cygwin app is piped
  to less, screen is sometimes distorted when the screen is resized.
  With this patch, ResizePseudoConsole() is not called if stdout is
  redirected.
---
 winsup/cygwin/fhandler_tty.cc | 8 ++--
 winsup/cygwin/tty.cc  | 1 +
 winsup/cygwin/tty.h   | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index c5a081ebd..600de085c 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1511,7 +1511,7 @@ fhandler_pty_common::resize_pseudo_console (struct 
winsize *ws)
   size.X = ws->ws_col;
   size.Y = ws->ws_row;
   pinfo p (get_ttyp ()->pcon_pid);
-  if (p)
+  if (p && !get_ttyp ()->do_not_resize_pcon)
 {
   HPCON_INTERNAL hpcon_local;
   HANDLE pcon_owner =
@@ -2489,7 +2489,10 @@ fhandler_pty_slave::setup_pseudoconsole (STARTUPINFOEXW 
*si, bool nopcon)
   si->StartupInfo.hStdInput = fh0->get_handle ();
 fhandler_base *fh1 = ::cygheap->fdtab[1];
 if (fh1 && fh1->get_device () != get_device ())
-  si->StartupInfo.hStdOutput = fh1->get_output_handle ();
+  {
+   get_ttyp ()->do_not_resize_pcon = true;
+   si->StartupInfo.hStdOutput = fh1->get_output_handle ();
+  }
 fhandler_base *fh2 = ::cygheap->fdtab[2];
 if (fh2 && fh2->get_device () != get_device ())
   si->StartupInfo.hStdError = fh2->get_output_handle ();
@@ -2535,6 +2538,7 @@ fhandler_pty_slave::close_pseudoconsole (void)
   get_ttyp ()->switch_to_pcon_in = false;
   get_ttyp ()->pcon_pid = 0;
   get_ttyp ()->pcon_start = false;
+  get_ttyp ()->do_not_resize_pcon = false;
 }
 }
 
diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc
index 7e3b88b0b..d4b8d7651 100644
--- a/winsup/cygwin/tty.cc
+++ b/winsup/cygwin/tty.cc
@@ -245,6 +245,7 @@ tty::init ()
   pcon_cap_checked = false;
   has_csi6n = false;
   has_set_title = false;
+  do_not_resize_pcon = false;
 }
 
 HANDLE
diff --git a/winsup/cygwin/tty.h b/winsup/cygwin/tty.h
index 4e9199dba..2c1ac7f5d 100644
--- a/winsup/cygwin/tty.h
+++ b/winsup/cygwin/tty.h
@@ -104,6 +104,7 @@ private:
   bool pcon_cap_checked;
   bool has_csi6n;
   bool has_set_title;
+  bool do_not_resize_pcon;
 
 public:
   HANDLE from_master () const { return _from_master; }
-- 
2.29.0