Re: [PATCH] Cygwin: remove %esp from asm clobber list

2020-02-28 Thread Johannes Schindelin
Hi,

On Fri, 28 Feb 2020, Jon Turney wrote:

> Mentioning the stack pointer in the clobber list is now a gcc warning.
>
> We never wanted gcc to try to restore %esp after this (x86-specific)
> asm, since the whole point of the inline asm here is to adjust %esp to
> satisfy alignment, so remove %esp from the asm clobber list.
>
> Of more concern is the alleged requirement that %esp must be unchanged
> over an asm statement (which makes what this code is trying to do
> impossible to write as a C function), although on x86 we are probably ok
> in this particular instance.
>
> ../../../../winsup/cygwin/init.cc: In function 'void threadfunc_fe(void*)':
> ../../../../winsup/cygwin/init.cc:33:46: error: listing the stack pointer 
> register '%esp' in a clobber list is deprecated [-Werror=deprecated]
> ../../../../winsup/cygwin/init.cc:33:46: note: the value of the stack pointer 
> after an 'asm' statement must be the same as it was before the statement
>
> Also, because we now using gcc's "basic" rather than "extended" asm
> syntax we don't need to escape the '%' in '%esp' as '%%esp'.
> ---
>
> Notes:
> N.B: This comes with a 'this should be ok, but I haven't actually
> tested that x86 Cygwin works after this' caveat.

We run with this patch in Git for Windows for quite a while, and I have
yet to hear complaints:

https://github.com/git-for-windows/msys2-runtime/commit/dd5aa267f6f28aef2a241cc7a01bb71a434b403c

As far as I can tell, MSYS2 does the same.

So there is at least some confirmation to be had ;-)

Ciao,
Dscho

>
>  winsup/cygwin/crt0.c  | 2 +-
>  winsup/cygwin/init.cc | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/winsup/cygwin/crt0.c b/winsup/cygwin/crt0.c
> index fee4b2e24..9fcebd8fa 100644
> --- a/winsup/cygwin/crt0.c
> +++ b/winsup/cygwin/crt0.c
> @@ -27,7 +27,7 @@ mainCRTStartup ()
>  #if __GNUC_PREREQ(6,0)
>  #pragma GCC diagnostic pop
>  #endif
> -  asm volatile ("andl $-16,%%esp" ::: "%esp");
> +  asm volatile ("andl $-16,%esp");
>  #endif
>
>cygwin_crt0 (main);
> diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
> index 851a7ffed..7ae7d08fe 100644
> --- a/winsup/cygwin/init.cc
> +++ b/winsup/cygwin/init.cc
> @@ -30,7 +30,7 @@ threadfunc_fe (VOID *arg)
>  #if __GNUC_PREREQ(6,0)
>  #pragma GCC diagnostic pop
>  #endif
> -  asm volatile ("andl $-16,%%esp" ::: "%esp");
> +  asm volatile ("andl $-16,%esp");
>  #endif
>_cygtls::call ((DWORD (*)  (void *, void *)) TlsGetValue (_my_oldfunc), 
> arg);
>  }
> --
> 2.21.0
>
>


Re: [ANN] Cygwin-OpenSSH 8.2.2.2

2020-02-28 Thread Andrey Repin
Greetings, Bill Stewart!

>> No, you must backport all sources to the current and all previous versions
>> and
>> redistribute, or at least make them visible and available on your site,
>> otherwise you are in breach of the licence and must withdraw all
>> distributions
>>

> I have removed the package. (The phrase "no good deed goes unpunished"
> comes to mind.)

> I will put up a separate package later that does not contain any cygwin
> binaries and write a script instead that can download the needed binaries
> and sources using the cygwin setup tool (that the user will have to
> download themselves).

You can download the setup yourself as part of installation process, just make
it clear to the user, what happening, make sure your download process is
sufficiently secure, and include the instructions, how to avoid this in case
the user already have Cygwin environment installed.

> In this way I will be hosting no binaries and will
> not be in violation of any license.


-- 
With best regards,
Andrey Repin
Saturday, February 29, 2020 0:16:46

Sorry for my terrible english...


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: [PATCH v2 1/4] Cygwin: console: Add workaround for broken IL/DL in xterm mode.

2020-02-28 Thread Hans-Bernhard Bröker

Am 28.02.2020 um 14:31 schrieb Corinna Vinschen:

[CC Hans]


Thanks.  I wasn't subscribed to -patches so far.  Will change that.


Hans,
as for making a patch for this issue, may I leave it to you
because you are already working on it?


My patch was meant only as a minimally-invasive stop-gap fix, because 
the new GCC refused to compile the code as-is (it triggers a 
-Werror...).  As such, sorry for hurting Brian's eyes. ;-)


I agree that this really should be an inline function.  I barely speak 
C++, but even I have glimpsed that multi-statement macros are rightfully 
frowned upon in C++ circles.


I believe a more C++-like implementation would have to encapsulate wpbuf 
and wpixput into a helper class.  This is what my _very_ rusty C++ 
allowed me to come up with:


// simple helper class to accumulate output in a buffer
// and send that to the console on request:
static class
{
private:
  unsigned char buf[WPBUF_LEN];
  int ixput;

public:
  inline void put(unsigned char x)
  {
if (ixput < WPBUF_LEN)
  {
buf[ixput++] = x;
  }
  };
  inline void empty() { ixput = 0; };
  inline void sendOut(HANDLE , DWORD *wn) {
WriteConsoleA (handle, buf, ixput, wn, 0);
  };
} wpbuf;

Using it works like this:

s/wpbuf_put/wpbuf.put/
s/wpixput = 0/wpbuf.empty()/
s/WriteConsoleA ( get_output_handle (), wpbuf, wpixput, \(*n\), 0 
/wpbuf.sendOut( get_output_handle (), \1/g


Yes, sendOut() is ugly --- I didn't manage to find out how this class 
could access get_output_handle() itself, so I had to let its callers 
deal with that.


Re: Has rename syntax changed?

2020-02-28 Thread Brian Inglis
On 2020-02-28 11:09, Lee wrote:
> On 2/28/20, Fergus Daly wrote:
>> I am almost certain that the command
>> $ rename "anything" "AnyThing" *.ext
>> would alter the string from lc to uc as shown, anywhere it occurred in any
>> filename in *.ext in the current directory.
>> What I remember as past behaviour now fails, leaving he filename unaltered.
>> (Failure in much the same way as mv would fail if the similar attempt was
>> made.)
>> (Good old DOS command rename (or the abbreviation ren) used to achieve
>> multiple-rename in an easy manner that just eludes bash.)
>> Anyway: has something altered (and quite recently, i think), or am I just
>> mis-remembering the versatility of the command rename?
> 
> Try it with the '-v' option
> 
> $ rename -v anything AnyThing *.ext
> `anything.ext' -> `AnyThing.ext'
> `xxanythingxx.ext' -> `xxAnyThingxx.ext'
> 
> $ rename -v AnyThing anything *.exe
> rename: *.exe: not accessible: No such file or directory
> 
> $ rename -v AnyThing anything *.ext
> `AnyThing.ext' -> `anything.ext'
> `xxAnyThingxx.ext' -> `xxanythingxx.ext'

This will always depend on the file system interface: DOS ignores case changes
as case is not supported, ExFAT/VFAT and everything else preserves case changes,
as do most remote file systems, unless the remote is set up case insensitively
to check the old and new names and ignore case changes (I've been annoyed by
that in the past, normally on proprietary file servers).

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Incorrect behavior in TIOCINQ ioctl

2020-02-28 Thread Corinna Vinschen
On Feb 27 22:38, Åke Rehnman wrote:
> Hi,
> 
> I recently ran in to some troubles with the TIOCINQ ioctl. I am wondering if
> the cygwin implementation is correct... It seems if there were any existing
> framing overrun errors etc etc  before calling the TIOCINQ ioctl it is
> returning an error (EINVAL). Reading through linux implmentation of TIOCINQ
> does simply return number of pending chars without any clearing or checking
> for errors.
> 
> I suggest the whole if (ev & CE_FRAME  .. ) is removed.
> 
> Excerpt from fhandler_serial.cc:
> 
> /* ioctl: */
> int
> fhandler_serial::ioctl (unsigned int cmd, void *buf)
> {
> .
> .
>   if (!ClearCommError (get_handle (), , ))
>     {
>   __seterrno ();
>   res = -1;
>     }
> .
> .
> .
>  case TIOCINQ:
>    if (ev & CE_FRAME || ev & CE_IOE || ev & CE_OVERRUN || ev & CE_RXOVER
>        || ev & CE_RXPARITY)
>      {
>        set_errno (EINVAL);    /* FIXME: Use correct errno */
>        res = -1;
>      }
>  else
>         ipbuf = st.cbInQue;
>  break;

I'm not familiar with serial I/O and the code is pretty stable(*).

- Is it a safe bet that ClearCommError returns valid values in
  st.cbInQue even if one of the error conditions occur?  Maybe the
  right thing to do is to return 0 in certain error cases...?

- Did you actually try if this fixes your problem?  It's pretty
  simple to build the Cygwin DLL
  https://cygwin.com/faq.html#faq.programming.building-cygwin


Corinna

(*) euphemistically for "nobody looked into the code for a long time"


-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: [PATCH v2 1/4] Cygwin: console: Add workaround for broken IL/DL in xterm mode.

2020-02-28 Thread Corinna Vinschen
On Feb 29 02:06, Takashi Yano wrote:
> On Fri, 28 Feb 2020 15:49:05 +0100
> Corinna Vinschen wrote:
> > Also, on second thought, given wpbuf is global inside this file, doesn't
> > this require guarding against multi-threaded access?
> 
> wpbuf_put() is used in write(), and almost whole of write()
> code is guarded by output_mutex. So, I think it is already
> thread-safe.

Ah, right, thanks.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: Has rename syntax changed?

2020-02-28 Thread Lee
On 2/28/20, Fergus Daly wrote:
> I am almost certain that the command
> $ rename "anything" "AnyThing" *.ext
> would alter the string from lc to uc as shown, anywhere it occurred in any
> filename in *.ext in the current directory.
> What I remember as past behaviour now fails, leaving he filename unaltered.
> (Failure in much the same way as mv would fail if the similar attempt was
> made.)
> (Good old DOS command rename (or the abbreviation ren) used to achieve
> multiple-rename in an easy manner that just eludes bash.)
> Anyway: has something altered (and quite recently, i think), or am I just
> mis-remembering the versatility of the command rename?

Try it with the '-v' option

$ rename -v anything AnyThing *.ext
`anything.ext' -> `AnyThing.ext'
`xxanythingxx.ext' -> `xxAnyThingxx.ext'

$ rename -v AnyThing anything *.exe
rename: *.exe: not accessible: No such file or directory

$ rename -v AnyThing anything *.ext
`AnyThing.ext' -> `anything.ext'
`xxAnyThingxx.ext' -> `xxanythingxx.ext'

Lee

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



setup 2.902 release candidate - please test

2020-02-28 Thread Jon Turney



A new setup release candidate is available at:

  https://cygwin.com/setup/setup-2.902.x86_64.exe (64 bit version)
  https://cygwin.com/setup/setup-2.902.x86.exe(32 bit version)

Please test, and report any problems here.

Changes compared to 2.901:

- Can now verify (using a public key provided with the --pubkey option) 
signatures made:


* using an RSA key

* using a DSA key with an alternate hash algorithm (e.g. 'gpg 
--enable-dsa2 --personal-digest-preferences=sha256' with a 1024D key)


* using multiple keys (i.e. the .sig file contains multiple signatures), 
where a signature from a known key is not the first one appearing.


- Embeds a new Cygwin public key (which nothing is actually signed with yet)

* The '--disable-old-keys' option disables use of the current Cygwin 
signing key.


- When run with the '--no-admin' option, restore output appearing in a 
Cygwin terminal (when using Cygwin 3.1.0 or later)


- Various code cleanups


Re: [ANN] Cygwin-OpenSSH 8.2.2.2

2020-02-28 Thread Andrew Schulman via cygwin
> On Thu, Feb 27, 2020 at 3:31 PM Brian Inglis wrote:
> 
> No, you must backport all sources to the current and all previous versions
> > and
> > redistribute, or at least make them visible and available on your site,
> > otherwise you are in breach of the licence and must withdraw all
> > distributions
> >
> 
> I have removed the package. (The phrase "no good deed goes unpunished"
> comes to mind.)

No cheering here about that. Thanks for contributing, and I hope your next
iteration is more successful. Andrew


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: [PATCH v2 1/4] Cygwin: console: Add workaround for broken IL/DL in xterm mode.

2020-02-28 Thread Takashi Yano
On Fri, 28 Feb 2020 15:49:05 +0100
Corinna Vinschen wrote:
> Also, on second thought, given wpbuf is global inside this file, doesn't
> this require guarding against multi-threaded access?

wpbuf_put() is used in write(), and almost whole of write()
code is guarded by output_mutex. So, I think it is already
thread-safe.

-- 
Takashi Yano 


Re: 1 [main] bash 3048 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer. Please report this problem to

2020-02-28 Thread cygwinautoreply
>1 [main] bash 3048 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointe=
>r.  Please report this problem to the public mailing list cygwin@cygwin.com=
>

>Cygwin wurde neu installiert.


https://cygwin.com/faq.html#faq.using.fixing-find_fast_cwd-warnings

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



1 [main] bash 3048 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer. Please report this problem to

2020-02-28 Thread Lampatzer, Rainer
1 [main] bash 3048 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer.  
Please report this problem to the public mailing list 
cygwin@cygwin.com

Cygwin wurde neu installiert.

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: OpenSSH: SSHD daemon (as SYSTEM) is partially broken

2020-02-28 Thread Bill Stewart
On Thu, Feb 27, 2020 at 4:10 PM TestUser1 wrote:

So is this expected to work fine in my environment, Windows Server 2016 (OS
> Version 10.0.14393), without the workaround?
>

 I can't reproduce on Windows Server 8.1/Server 2012 R2 or later.

But you can certainly try the workaround.

Bill

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: [ANN] Cygwin-OpenSSH 8.2.2.2

2020-02-28 Thread Bill Stewart
On Thu, Feb 27, 2020 at 3:31 PM Brian Inglis wrote:

No, you must backport all sources to the current and all previous versions
> and
> redistribute, or at least make them visible and available on your site,
> otherwise you are in breach of the licence and must withdraw all
> distributions
>

I have removed the package. (The phrase "no good deed goes unpunished"
comes to mind.)

I will put up a separate package later that does not contain any cygwin
binaries and write a script instead that can download the needed binaries
and sources using the cygwin setup tool (that the user will have to
download themselves). In this way I will be hosting no binaries and will
not be in violation of any license.

Bill

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: [PATCH v2 1/4] Cygwin: console: Add workaround for broken IL/DL in xterm mode.

2020-02-28 Thread Corinna Vinschen
On Feb 28 15:44, Corinna Vinschen wrote:
> On Feb 28 14:31, Corinna Vinschen wrote:
> > [CC Hans]
> > 
> > On Feb 28 11:14, Takashi Yano wrote:
> > > On Thu, 27 Feb 2020 18:03:47 +
> > > Jon Turney wrote:
> > > > > +#define wpbuf_put(x) \
> > > > > +  wpbuf[wpixput++] = x; \
> > > > > +  if (wpixput > WPBUF_LEN) \
> > > > > +wpixput--;
> > > > > +
> > > > 
> > > > So I think either the macro need it contents contained by a 'do { ... } 
> > > > while(0)',  or that instance of it needs to be surrounded by braces, to 
> > > > do what you intend.
> > > 
> > > Thanks for the advice. Fortunately, "if" statement does not
> > > cause a problem even if it is accidentally executed outside
> > > "else" block in this case.
> > > 
> > > Hans,
> > > as for making a patch for this issue, may I leave it to you
> > > because you are already working on it? 
> > > 
> > > -- 
> > > Takashi Yano 
> 
> What about an inline function instead?
> 
> diff --git a/winsup/cygwin/fhandler_console.cc 
> b/winsup/cygwin/fhandler_console.cc
> index 64e12b8320a1..6c3e33818aca 100644
> --- a/winsup/cygwin/fhandler_console.cc
> +++ b/winsup/cygwin/fhandler_console.cc
> @@ -63,10 +63,14 @@ static struct fhandler_base::rabuf_t con_ra;
>  static unsigned char wpbuf[WPBUF_LEN];
>  static int wpixput;
>  static unsigned char last_char;
> -#define wpbuf_put(x) \
> -  wpbuf[wpixput++] = x; \
> -  if (wpixput > WPBUF_LEN) \
> +
> +static inline void
> +wpbuf_put (unsigned char x)
> +{
> +  wpbuf[wpixput++] = x;
> +  if (wpixput > WPBUF_LEN)
>  wpixput--;
> +}

Also, on second thought, given wpbuf is global inside this file, doesn't
this require guarding against multi-threaded access?


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Re: [PATCH] Cygwin: console: Adjust the detailed behaviour of ESC sequences.

2020-02-28 Thread Corinna Vinschen
On Feb 27 11:33, Takashi Yano wrote:
> - This patch makes some detailed behaviour of ESC sequences such as
>   "CSI Ps L" (IL), "CSI Ps M" (DL) and "ESC M" (RI) in xterm mode
>   match with real xterm.
> ---
>  winsup/cygwin/fhandler.h  |  1 +
>  winsup/cygwin/fhandler_console.cc | 51 ++-
>  2 files changed, 45 insertions(+), 7 deletions(-)

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


[newlib-cygwin] Cygwin: console: Adjust the detailed behaviour of ESC sequences.

2020-02-28 Thread Corinna Vinschen
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=002206dc7cac5f3cc4d1282439c7a0c619a37b7f

commit 002206dc7cac5f3cc4d1282439c7a0c619a37b7f
Author: Takashi Yano 
Date:   Thu Feb 27 11:33:50 2020 +0900

Cygwin: console: Adjust the detailed behaviour of ESC sequences.

- This patch makes some detailed behaviour of ESC sequences such as
  "CSI Ps L" (IL), "CSI Ps M" (DL) and "ESC M" (RI) in xterm mode
  match with real xterm.

Diff:
---
 winsup/cygwin/fhandler.h  |  1 +
 winsup/cygwin/fhandler_console.cc | 51 +--
 2 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 90805ab..adaf192 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1862,6 +1862,7 @@ class dev_console
   bool saw_question_mark;
   bool saw_greater_than_sign;
   bool saw_space;
+  bool saw_exclamation_mark;
   bool vt100_graphics_mode_G0;
   bool vt100_graphics_mode_G1;
   bool iso_2022_G1;
diff --git a/winsup/cygwin/fhandler_console.cc 
b/winsup/cygwin/fhandler_console.cc
index 4ab9bca..64e12b8 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -2053,6 +2053,19 @@ fhandler_console::char_command (char c)
{
  /* Use "CSI Ps T" instead */
  cursor_get (, );
+ if (y < srTop || y > srBottom)
+   break;
+ if (y == con.b.srWindow.Top
+ && srBottom == con.b.srWindow.Bottom)
+   {
+ /* Erase scroll down area */
+ n = con.args[0] ? : 1;
+ __small_sprintf (buf, "\033[%d;1H\033[J\033[%d;%dH",
+  srBottom - (n-1) - con.b.srWindow.Top + 1,
+  y + 1 - con.b.srWindow.Top, x + 1);
+ WriteConsoleA (get_output_handle (),
+buf, strlen (buf), , 0);
+   }
  __small_sprintf (buf, "\033[%d;%dr",
   y + 1 - con.b.srWindow.Top,
   srBottom + 1 - con.b.srWindow.Top);
@@ -2079,6 +2092,8 @@ fhandler_console::char_command (char c)
{
  /* Use "CSI Ps S" instead */
  cursor_get (, );
+ if (y < srTop || y > srBottom)
+   break;
  __small_sprintf (buf, "\033[%d;%dr",
   y + 1 - con.b.srWindow.Top,
   srBottom + 1 - con.b.srWindow.Top);
@@ -2137,6 +2152,16 @@ fhandler_console::char_command (char c)
fix_tab_position ();
}
  break;
+   case 'p':
+ if (con.saw_exclamation_mark) /* DECSTR Soft reset */
+   {
+ con.scroll_region.Top = 0;
+ con.scroll_region.Bottom = -1;
+   }
+ wpbuf_put (c);
+ /* Just send the sequence */
+ WriteConsoleA (get_output_handle (), wpbuf, wpixput, , 0);
+ break;
default:
  /* Other escape sequences */
  wpbuf_put (c);
@@ -2970,6 +2995,7 @@ fhandler_console::write (const void *vsrc, size_t len)
  con.saw_question_mark = false;
  con.saw_greater_than_sign = false;
  con.saw_space = false;
+ con.saw_exclamation_mark = false;
}
  else if (wincap.has_con_24bit_colors () && !con_is_legacy
   && wincap.has_con_broken_il_dl () && *src == 'M')
@@ -2979,13 +3005,17 @@ fhandler_console::write (const void *vsrc, size_t len)
  cursor_get (, );
  if (y == srTop)
{
- /* Erase scroll down area */
- char buf[] = "\033[32768;1H\033[J\033[32768;32768";
- __small_sprintf (buf, "\033[%d;1H\033[J\033[%d;%dH",
-srBottom - con.b.srWindow.Top + 1,
-y + 1 - con.b.srWindow.Top, x + 1);
- WriteConsoleA (get_output_handle (),
-buf, strlen (buf), , 0);
+ if (y == con.b.srWindow.Top
+ && srBottom == con.b.srWindow.Bottom)
+   {
+ /* Erase scroll down area */
+ char buf[] = "\033[32768;1H\033[J\033[32768;32768";
+ __small_sprintf (buf, "\033[%d;1H\033[J\033[%d;%dH",
+  srBottom - con.b.srWindow.Top + 1,
+  y + 1 - con.b.srWindow.Top, x + 1);
+ WriteConsoleA (get_output_handle (),
+buf, strlen (buf), , 0);
+   }
  /* Substitute "CSI Ps T" */
  wpbuf_put ('[');
  wpbuf_put ('T');
@@ -2998,6 +3028,11 @@ fhandler_console::write (const void *vsrc, size_t len)
}
  else if (wincap.has_con_24bit_colors 

Re: [PATCH v2 1/4] Cygwin: console: Add workaround for broken IL/DL in xterm mode.

2020-02-28 Thread Corinna Vinschen
On Feb 28 14:31, Corinna Vinschen wrote:
> [CC Hans]
> 
> On Feb 28 11:14, Takashi Yano wrote:
> > On Thu, 27 Feb 2020 18:03:47 +
> > Jon Turney wrote:
> > > > +#define wpbuf_put(x) \
> > > > +  wpbuf[wpixput++] = x; \
> > > > +  if (wpixput > WPBUF_LEN) \
> > > > +wpixput--;
> > > > +
> > > 
> > > So I think either the macro need it contents contained by a 'do { ... } 
> > > while(0)',  or that instance of it needs to be surrounded by braces, to 
> > > do what you intend.
> > 
> > Thanks for the advice. Fortunately, "if" statement does not
> > cause a problem even if it is accidentally executed outside
> > "else" block in this case.
> > 
> > Hans,
> > as for making a patch for this issue, may I leave it to you
> > because you are already working on it? 
> > 
> > -- 
> > Takashi Yano 

What about an inline function instead?

diff --git a/winsup/cygwin/fhandler_console.cc 
b/winsup/cygwin/fhandler_console.cc
index 64e12b8320a1..6c3e33818aca 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -63,10 +63,14 @@ static struct fhandler_base::rabuf_t con_ra;
 static unsigned char wpbuf[WPBUF_LEN];
 static int wpixput;
 static unsigned char last_char;
-#define wpbuf_put(x) \
-  wpbuf[wpixput++] = x; \
-  if (wpixput > WPBUF_LEN) \
+
+static inline void
+wpbuf_put (unsigned char x)
+{
+  wpbuf[wpixput++] = x;
+  if (wpixput > WPBUF_LEN)
 wpixput--;
+}
 
 static void
 beep ()


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


[newlib-cygwin] Cygwin: AF_UNIX: rework fixup_after_exec

2020-02-28 Thread Corinna Vinschen
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=729cb70bcf232a1da956ec3725c1f76e28b3caa5

commit 729cb70bcf232a1da956ec3725c1f76e28b3caa5
Author: Corinna Vinschen 
Date:   Fri Feb 28 13:21:05 2020 +0100

Cygwin: AF_UNIX: rework fixup_after_exec

fhandler_socket_unix::fixup_after_exec incorrectly calls
fhandler_socket_unix::fixup_after_fork with a NULL parent process
handle.  Not only that calling DuplicateHandle with a NULL parent
handle fails, but it's utterly wrong trying to duplicate the handles
at all here.

Rather just set some important values to NULL and reopen the shared
memory region.  Create a fixup_helper method to call common code from
fixup_after_fork and fixup_after_exec.

Add comments to other invocations of fixup_after_fork with NULL
handle to mark them as correct this way.

Signed-off-by: Corinna Vinschen 

Diff:
---
 winsup/cygwin/fhandler.h  |  1 +
 winsup/cygwin/fhandler_socket_inet.cc |  2 +-
 winsup/cygwin/fhandler_socket_unix.cc | 21 +
 winsup/cygwin/fhandler_tty.cc |  2 +-
 4 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 55f18ae..90805ab 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1076,6 +1076,7 @@ class fhandler_socket_unix : public fhandler_socket
   void fixup_after_fork (HANDLE parent);
   void fixup_after_exec ();
   void set_close_on_exec (bool val);
+  void fixup_helper ();
 
  public:
   fhandler_socket_unix ();
diff --git a/winsup/cygwin/fhandler_socket_inet.cc 
b/winsup/cygwin/fhandler_socket_inet.cc
index 6f43838..703781d 100644
--- a/winsup/cygwin/fhandler_socket_inet.cc
+++ b/winsup/cygwin/fhandler_socket_inet.cc
@@ -534,7 +534,7 @@ void
 fhandler_socket_wsock::fixup_after_exec ()
 {
   if (need_fixup_before () && !close_on_exec ())
-fixup_after_fork (NULL);
+fixup_after_fork (NULL);   /* No parent handle required. */
 }
 
 int
diff --git a/winsup/cygwin/fhandler_socket_unix.cc 
b/winsup/cygwin/fhandler_socket_unix.cc
index 760f210..d7bb109 100644
--- a/winsup/cygwin/fhandler_socket_unix.cc
+++ b/winsup/cygwin/fhandler_socket_unix.cc
@@ -1149,6 +1149,16 @@ fhandler_socket_unix::set_cred ()
   scred->gid = myself->gid;
 }
 
+void
+fhandler_socket_unix::fixup_helper ()
+{
+  if (shmem_handle)
+reopen_shmem ();
+  connect_wait_thr = NULL;
+  cwt_termination_evt = NULL;
+  cwt_param = NULL;
+}
+
 /* == public methods = */
 
 void
@@ -1158,20 +1168,15 @@ fhandler_socket_unix::fixup_after_fork (HANDLE parent)
   if (backing_file_handle && backing_file_handle != INVALID_HANDLE_VALUE)
 fork_fixup (parent, backing_file_handle, "backing_file_handle");
   if (shmem_handle)
-{
-  fork_fixup (parent, shmem_handle, "shmem_handle");
-  reopen_shmem ();
-}
-  connect_wait_thr = NULL;
-  cwt_termination_evt = NULL;
-  cwt_param = NULL;
+fork_fixup (parent, shmem_handle, "shmem_handle");
+  fixup_helper ();
 }
 
 void
 fhandler_socket_unix::fixup_after_exec ()
 {
   if (!close_on_exec ())
-fixup_after_fork (NULL);
+fixup_helper ();
 }
 
 void
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 153bdad..b42e0ae 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2974,7 +2974,7 @@ fhandler_pty_slave::fixup_after_exec ()
   reset_switch_to_pcon ();
 
   if (!close_on_exec ())
-fixup_after_fork (NULL);
+fixup_after_fork (NULL);   /* No parent handle required. */
   else if (get_pseudo_console ())
 {
   int used = 0;


Re: [PATCH] Cygwin: remove %esp from asm clobber list

2020-02-28 Thread Corinna Vinschen
On Feb 28 12:04, Jon Turney wrote:
> Mentioning the stack pointer in the clobber list is now a gcc warning.
> 
> We never wanted gcc to try to restore %esp after this (x86-specific)
> asm, since the whole point of the inline asm here is to adjust %esp to
> satisfy alignment, so remove %esp from the asm clobber list.
> 
> Of more concern is the alleged requirement that %esp must be unchanged
> over an asm statement (which makes what this code is trying to do
> impossible to write as a C function), although on x86 we are probably ok
> in this particular instance.
> 
> ../../../../winsup/cygwin/init.cc: In function 'void threadfunc_fe(void*)':
> ../../../../winsup/cygwin/init.cc:33:46: error: listing the stack pointer 
> register '%esp' in a clobber list is deprecated [-Werror=deprecated]
> ../../../../winsup/cygwin/init.cc:33:46: note: the value of the stack pointer 
> after an 'asm' statement must be the same as it was before the statement
> 
> Also, because we now using gcc's "basic" rather than "extended" asm
> syntax we don't need to escape the '%' in '%esp' as '%%esp'.
> ---

As discussed on IRC, let's try to fix that using the gcc funtion
attribute force_align_arg_pointer, as Mingw-w64 already did in 2018.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


[newlib-cygwin] Cygwin: 32 bit: remove old code to 16 bit align stack

2020-02-28 Thread Corinna Vinschen
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a834dc1ba923d33a87f0dc3be0e23a9aa81603b8

commit a834dc1ba923d33a87f0dc3be0e23a9aa81603b8
Author: Corinna Vinschen 
Date:   Fri Feb 28 14:31:56 2020 +0100

Cygwin: 32 bit: remove old code to 16 bit align stack

Aligning the stack pointer using an asm statement isn't any longer
supported.  gcc-9.2.0 generates the following warning:

  init.cc:33:46: error: listing the stack pointer register '%esp'
  in a clobber list is deprecated [-Werror=deprecated]
  [...]
  init.cc:33:46: note: the value of the stack pointer after an
  'asm' statement must be the same as it was before the statement

Replace the asm expression with the gcc function attribute
`force_align_arg_pointer'.  This aligns the stack exactly as
required.

Signed-off-by: Corinna Vinschen 

Diff:
---
 winsup/cygwin/crt0.c  | 14 +++---
 winsup/cygwin/init.cc | 13 +++--
 2 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/winsup/cygwin/crt0.c b/winsup/cygwin/crt0.c
index fee4b2e..ec7959a 100644
--- a/winsup/cygwin/crt0.c
+++ b/winsup/cygwin/crt0.c
@@ -16,20 +16,12 @@ extern int main (int argc, char **argv);
 
 void cygwin_crt0 (int (*main) (int, char **));
 
+#ifdef __i386__
+__attribute__ ((force_align_arg_pointer))
+#endif
 void
 mainCRTStartup ()
 {
-#ifdef __i386__
-#if __GNUC_PREREQ(6,0)
-#pragma GCC diagnostic ignored "-Wframe-address"
-#endif
-  (void)__builtin_return_address(1);
-#if __GNUC_PREREQ(6,0)
-#pragma GCC diagnostic pop
-#endif
-  asm volatile ("andl $-16,%%esp" ::: "%esp");
-#endif
-
   cygwin_crt0 (main);
 
   /* These are never actually called.  They are just here to force the 
inclusion
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index 851a7ff..7787b16 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -19,19 +19,12 @@ unsigned threadfunc_ix[8];
 static bool dll_finished_loading;
 #define OLDFUNC_OFFSET -1
 
+#ifdef __i386__
+__attribute__ ((force_align_arg_pointer))
+#endif
 static void WINAPI
 threadfunc_fe (VOID *arg)
 {
-#ifdef __i386__
-#if __GNUC_PREREQ(6,0)
-#pragma GCC diagnostic ignored "-Wframe-address"
-#endif
-  (void)__builtin_return_address(1);
-#if __GNUC_PREREQ(6,0)
-#pragma GCC diagnostic pop
-#endif
-  asm volatile ("andl $-16,%%esp" ::: "%esp");
-#endif
   _cygtls::call ((DWORD (*)  (void *, void *)) TlsGetValue (_my_oldfunc), arg);
 }


Re: [PATCH v2 1/4] Cygwin: console: Add workaround for broken IL/DL in xterm mode.

2020-02-28 Thread Corinna Vinschen
[CC Hans]

On Feb 28 11:14, Takashi Yano wrote:
> On Thu, 27 Feb 2020 18:03:47 +
> Jon Turney wrote:
> > > +#define wpbuf_put(x) \
> > > +  wpbuf[wpixput++] = x; \
> > > +  if (wpixput > WPBUF_LEN) \
> > > +wpixput--;
> > > +
> > 
> > So I think either the macro need it contents contained by a 'do { ... } 
> > while(0)',  or that instance of it needs to be surrounded by braces, to 
> > do what you intend.
> 
> Thanks for the advice. Fortunately, "if" statement does not
> cause a problem even if it is accidentally executed outside
> "else" block in this case.
> 
> Hans,
> as for making a patch for this issue, may I leave it to you
> because you are already working on it? 
> 
> -- 
> Takashi Yano 

-- 
Corinna Vinschen
Cygwin Maintainer


signature.asc
Description: PGP signature


Has rename syntax changed?

2020-02-28 Thread Fergus Daly
I am almost certain that the command
$ rename "anything" "AnyThing" *.ext
would alter the string from lc to uc as shown, anywhere it occurred in any 
filename in *.ext in the current directory.
What I remember as past behaviour now fails, leaving he filename unaltered.
(Failure in much the same way as mv would fail if the similar attempt was made.)
(Good old DOS command rename (or the abbreviation ren) used to achieve 
multiple-rename in an easy manner that just eludes bash.)
Anyway: has something altered (and quite recently, i think), or am I just 
mis-remembering the versatility of the command rename?
Fergus  

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



[PATCH] Cygwin: remove %esp from asm clobber list

2020-02-28 Thread Jon Turney
Mentioning the stack pointer in the clobber list is now a gcc warning.

We never wanted gcc to try to restore %esp after this (x86-specific)
asm, since the whole point of the inline asm here is to adjust %esp to
satisfy alignment, so remove %esp from the asm clobber list.

Of more concern is the alleged requirement that %esp must be unchanged
over an asm statement (which makes what this code is trying to do
impossible to write as a C function), although on x86 we are probably ok
in this particular instance.

../../../../winsup/cygwin/init.cc: In function 'void threadfunc_fe(void*)':
../../../../winsup/cygwin/init.cc:33:46: error: listing the stack pointer 
register '%esp' in a clobber list is deprecated [-Werror=deprecated]
../../../../winsup/cygwin/init.cc:33:46: note: the value of the stack pointer 
after an 'asm' statement must be the same as it was before the statement

Also, because we now using gcc's "basic" rather than "extended" asm
syntax we don't need to escape the '%' in '%esp' as '%%esp'.
---

Notes:
N.B: This comes with a 'this should be ok, but I haven't actually
tested that x86 Cygwin works after this' caveat.

 winsup/cygwin/crt0.c  | 2 +-
 winsup/cygwin/init.cc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/crt0.c b/winsup/cygwin/crt0.c
index fee4b2e24..9fcebd8fa 100644
--- a/winsup/cygwin/crt0.c
+++ b/winsup/cygwin/crt0.c
@@ -27,7 +27,7 @@ mainCRTStartup ()
 #if __GNUC_PREREQ(6,0)
 #pragma GCC diagnostic pop
 #endif
-  asm volatile ("andl $-16,%%esp" ::: "%esp");
+  asm volatile ("andl $-16,%esp");
 #endif
 
   cygwin_crt0 (main);
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index 851a7ffed..7ae7d08fe 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -30,7 +30,7 @@ threadfunc_fe (VOID *arg)
 #if __GNUC_PREREQ(6,0)
 #pragma GCC diagnostic pop
 #endif
-  asm volatile ("andl $-16,%%esp" ::: "%esp");
+  asm volatile ("andl $-16,%esp");
 #endif
   _cygtls::call ((DWORD (*)  (void *, void *)) TlsGetValue (_my_oldfunc), arg);
 }
-- 
2.21.0



[newlib-cygwin] Cygwin: AF_UNIX: use Nt functions within Nt functions

2020-02-28 Thread Corinna Vinschen
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f5357141ade956d8057e76b0a5e58f5069a6d399

commit f5357141ade956d8057e76b0a5e58f5069a6d399
Author: Corinna Vinschen 
Date:   Fri Feb 28 12:40:49 2020 +0100

Cygwin: AF_UNIX: use Nt functions within Nt functions

Functionaly equivalent, but makes for cleaner code

Signed-off-by: Corinna Vinschen 

Diff:
---
 winsup/cygwin/fhandler_socket_unix.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/fhandler_socket_unix.cc 
b/winsup/cygwin/fhandler_socket_unix.cc
index 824bcba..760f210 100644
--- a/winsup/cygwin/fhandler_socket_unix.cc
+++ b/winsup/cygwin/fhandler_socket_unix.cc
@@ -1436,10 +1436,10 @@ fhandler_socket_unix::socketpair (int af, int type, int 
protocol, int flags,
 fh_open_pipe_failed:
   NtClose (pipe);
 create_pipe_failed:
-  NtUnmapViewOfSection (GetCurrentProcess (), fh->shmem);
+  NtUnmapViewOfSection (NtCurrentProcess (), fh->shmem);
   NtClose (fh->shmem_handle);
 fh_shmem_failed:
-  NtUnmapViewOfSection (GetCurrentProcess (), shmem);
+  NtUnmapViewOfSection (NtCurrentProcess (), shmem);
   NtClose (shmem_handle);
   return -1;
 }
@@ -1814,7 +1814,7 @@ fhandler_socket_unix::close ()
 NtClose (shm);
   param = InterlockedExchangePointer ((PVOID *) , NULL);
   if (param)
-NtUnmapViewOfSection (GetCurrentProcess (), param);
+NtUnmapViewOfSection (NtCurrentProcess (), param);
   return 0;
 }


[newlib-cygwin] Cygwin: AF_UNIX: fix creating shared mem region in dup

2020-02-28 Thread Corinna Vinschen
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=92b8b300c26c20ea441f69b36da9a838aa85c2d8

commit 92b8b300c26c20ea441f69b36da9a838aa85c2d8
Author: Corinna Vinschen 
Date:   Fri Feb 28 12:39:41 2020 +0100

Cygwin: AF_UNIX: fix creating shared mem region in dup

reopen_shmem is accidentally called on the parent fhandler
rather than the child fhandler, and it's called too early.
Make sure to call it on the child and only after its shmem_handle
is valid.

Signed-off-by: Corinna Vinschen 

Diff:
---
 winsup/cygwin/fhandler_socket_unix.cc | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/winsup/cygwin/fhandler_socket_unix.cc 
b/winsup/cygwin/fhandler_socket_unix.cc
index eea7e76..824bcba 100644
--- a/winsup/cygwin/fhandler_socket_unix.cc
+++ b/winsup/cygwin/fhandler_socket_unix.cc
@@ -1201,12 +1201,6 @@ fhandler_socket_unix::dup (fhandler_base *child, int 
flags)
   return -1;
 }
   fhandler_socket_unix *fhs = (fhandler_socket_unix *) child;
-  if (reopen_shmem () < 0)
-{
-  __seterrno ();
-  fhs->close ();
-  return -1;
-}
   if (backing_file_handle && backing_file_handle != INVALID_HANDLE_VALUE
   && !DuplicateHandle (GetCurrentProcess (), backing_file_handle,
GetCurrentProcess (), >backing_file_handle,
@@ -1224,6 +1218,12 @@ fhandler_socket_unix::dup (fhandler_base *child, int 
flags)
   fhs->close ();
   return -1;
 }
+  if (fhs->reopen_shmem () < 0)
+{
+  __seterrno ();
+  fhs->close ();
+  return -1;
+}
   fhs->sun_path (sun_path ());
   fhs->peer_sun_path (peer_sun_path ());
   fhs->connect_wait_thr = NULL;