www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/07/18/05:03:24

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 56I93NKJ2461532
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 56I93NKJ2461532
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=SWGc5T88
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 830483852743
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1752829402;
bh=i0fTvgfwSy7BtcMRRIH9gp9UEF3GxNfN6vu1GFGq/0I=;
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=SWGc5T88B0VNjNJepaxQ+J4eNydd5pEfRKVwNvot4g+8qbD6mcAo/22X87hKW2i1V
Ek7VoCJw9wOno1h1KTK0XTCIMK8WwdBcJzL7ZcZead9FyLkMbWBfcfMpqOUKryYiOY
I1aBK310qczcXjTxrgDHQ8yzXNnnNNATY7w/B9AE=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56C85385E443
Date: Fri, 18 Jul 2025 11:02:20 +0200
To: Zachary Santer <zsanter AT gmail DOT com>
Subject: Re: sys/termios.h defines struct winsize after it is referenced in
function signatures
Message-ID: <aHoNnPCDwPT7KX4F@calimero.vinschen.de>
Mail-Followup-To: Zachary Santer <zsanter AT gmail DOT com>,
Chester Ramey <chet DOT ramey AT case DOT edu>, cygwin AT cygwin DOT com,
Sam James <sam AT gentoo DOT org>, John Sidles <jasidles AT gmail DOT com>,
bug-bash <bug-bash AT gnu DOT org>
References: <CABkLJUKAXQqgdLappyNRY_swNBfYaNna73zWyDkXOqStmgR7hA AT mail DOT gmail DOT com>
<55ff90b3-5d56-4297-ac71-b398d4a54e62 AT case DOT edu>
<CABkLJUJt_a5Qkng-A8so8U_5iS0VnX=sWhC-3dyakxqe8WSyWA AT mail DOT gmail DOT com>
<acfa1dd3-0adb-4400-8890-4e8ef47ee46a AT case DOT edu>
<CABkLJUKKQt4pBLVnY37R8iZJ5_V4+B9-NqNX39KU-mk41VE43A AT mail DOT gmail DOT com>
<bd0be997-edfc-47d5-9bce-3d26fa7f4079 AT case DOT edu>
<CABkLJU+-fwghZwvTLZ=w7G7th9zsV2Wb6iUY_ky5Gho0+THraQ AT mail DOT gmail DOT com>
<877c072d5r DOT fsf AT gentoo DOT org>
<d7bbc429-bc10-4d87-a157-fdf1b3d7bd41 AT case DOT edu>
<CABkLJU+_r2x0m4XjQofeZDQhgprSWy87e3exmL+53tqBgfEaPg AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <CABkLJU+_r2x0m4XjQofeZDQhgprSWy87e3exmL+53tqBgfEaPg@mail.gmail.com>
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>,
Chester Ramey <chet DOT ramey AT case DOT edu>, cygwin AT cygwin DOT com,
Sam James <sam AT gentoo DOT org>, John Sidles <jasidles AT gmail DOT com>,
bug-bash <bug-bash AT gnu DOT org>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 56I93NKJ2461532

Hi Zachary,

thanks for the report.  I pushed a patch.  This will show up in
the next Cygwin release 3.6.5.

https://sourceware.org/cgit/newlib-cygwin/commit/?id=73600d68227e


Thanks,
Corinna


On Jul 18 00:02, Zachary Santer via Cygwin wrote:
> Was "MacOS Homebrew bash '5.3.0(1)-release' breaks 'wait' (?)" on
> bug-bash AT gnu DOT org.
> 
> On Thu, Jul 17, 2025 at 12:05 PM Chet Ramey <chet DOT ramey AT case DOT edu> wrote:
> >
> > On 7/17/25 8:51 AM, Sam James wrote:
> > > Zachary Santer <zsanter AT gmail DOT com> writes:
> > >
> > >> I've applied your patch, but gcc 15.1.0 has decided that a 'struct
> > >> winsize *' not being a 'struct winsize *' is an error now.
> > >>
> > >> Configuration Information [Automatically generated, do not change]:
> > >> Machine: x86_64
> > >> OS: cygwin
> > >> Compiler: gcc
> > >> Compilation CFLAGS: -Wno-error=incompatible-pointer-types
> > >> uname output: MSYS_NT-10.0-26100 Zack2021HPPavilion
> > >> 3.6.3-ab81aae6.x86_64 2025-07-01 18:20 UTC x86_64 Msys
> > >> Machine Type: x86_64-pc-cygwin
> > >>
> > >> Bash Version: 5.3
> > >> Patch Level: 0
> > >> Release Status: maint
> > >>
> > >> Would be nice if bashbug were generated even if bash itself failed to build.
> > >>
> > >>  From before I changed CFLAGS, obviously:
> > >>
> > >> winsize.c: In function 'get_new_window_size':
> > >> winsize.c:98:39: error: passing argument 2 of 'tcgetwinsize' from
> > >> incompatible pointer type [-Wincompatible-pointer-types]
> > >>     98 |   if (tty >= 0 && (tcgetwinsize (tty, &win) == 0) &&
> > >> win.ws_row > 0 && win.ws_col > 0)
> > >>        |                                       ^~~~
> > >>        |                                       |
> > >>        |                                       struct winsize *
> > >> In file included from /usr/include/sys/ioctl.h:15,
> > >>                   from winsize.c:31:
> > >> /usr/include/sys/termios.h:304:42: note: expected 'struct winsize *'
> > >> but argument is of type 'struct winsize *'
> > >>    304 | int tcgetwinsize(int fd, struct winsize *winsz);
> > >
> > > This is probably a visibility of the type issue:
> > > https://gcc.gnu.org/PR117866.
> >
> > OK. Where is `struct winsize' declared if not in termios.h or ioctl.h
> > (or the nest of includes for old systems)?
> >
> > https://pubs.opengroup.org/onlinepubs/9799919799/functions/tcgetwinsize.html#tag_17_609
> >
> > says that if libc has tcgetwinsize(), you only need <termios.h> to get
> > its declaration.
> 
> I've attached the /usr/include/sys/termios.h file included in my MSYS2
> installation. As you can see, struct winsize is defined after it is
> referenced in the function declarations of tcgetwinsize() and
> tcsetwinsize() in that file.
> 
> I moved the definition of struct winsize to above the function
> declarations, and bash built without issue.
> 
> This is a Cygwin bug, so I've included their email list on the To:
> line. The MSYS2 people don't use an email list anymore, so if I need
> to get in touch with them, I'll have to file an issue on their Github.
> 
> --- orig/termios.h 2025-07-17 23:26:00.518408600 -0400
> +++ fixed/termios.h 2025-07-17 23:28:00.517939200 -0400
> @@ -284,6 +284,13 @@
> 
>  #define termio termios
> 
> +/* Extra stuff to make porting stuff easier.  */
> +struct winsize
> +{
> +  unsigned short ws_row, ws_col;
> +  unsigned short ws_xpixel, ws_ypixel;
> +};
> +
>  #ifdef __cplusplus
>  extern "C" {
>  #endif
> @@ -313,13 +320,6 @@
>  #define cfgetospeed(tp) ((tp)->c_ospeed)
>  #endif
> 
> -/* Extra stuff to make porting stuff easier.  */
> -struct winsize
> -{
> -  unsigned short ws_row, ws_col;
> -  unsigned short ws_xpixel, ws_ypixel;
> -};
> -
>  #define TIOCGWINSZ (('T' << 8) | 1)
>  #define TIOCSWINSZ (('T' << 8) | 2)
>  #define TIOCLINUX  (('T' << 8) | 3)

> /* sys/termios.h
> 
> This file is part of Cygwin.
> 
> This software is a copyrighted work licensed under the terms of the
> Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
> details. */
> 
> /* sys/termios.h */
> 
> #ifndef	_SYS_TERMIOS_H
> #define _SYS_TERMIOS_H
> 
> #include <sys/types.h>
> 
> #define	TIOCMGET	0x5415
> #define	TIOCMBIS	0x5416
> #define	TIOCMBIC	0x5417
> #define	TIOCMSET	0x5418
> #define	TIOCINQ		0x541B
> #define TIOCSCTTY	0x540E
> 
> /* TIOCINQ is utilized instead of FIONREAD which has been
> accupied for other purposes under CYGWIN.
> Other UNIX ioctl requests has been omited because
> effects of their work one can achive by standard
> POSIX commands */
> 
> #define TIOCSBRK	0x5427
> #define TIOCCBRK	0x5428
> 
> #define	TIOCM_DTR	0x002
> #define	TIOCM_RTS	0x004
> #define	TIOCM_CTS	0x020
> #define	TIOCM_CAR	0x040
> #define	TIOCM_RNG	0x080
> #define	TIOCM_DSR	0x100
> #define	TIOCM_CD	TIOCM_CAR
> #define	TIOCM_RI	TIOCM_RNG
> 
> #define TCOOFF		0
> #define TCOON		1
> #define TCIOFF		2
> #define TCION		3
> 
> #define TCGETA	5
> #define TCSETA	6
> #define TCSETAW		7
> #define TCSETAF		8
> 
> #define TCIFLUSH	0
> #define TCOFLUSH	1
> #define TCIOFLUSH	2
> #define TCFLSH          3
> 
> #define TCSAFLUSH	1
> #define TCSANOW		2
> #define TCSADRAIN	3
> #define TCSADFLUSH	4
> 
> #define TIOCPKT		6
> 
> #define TIOCPKT_DATA		 0
> #define TIOCPKT_FLUSHREAD	 1
> #define TIOCPKT_FLUSHWRITE	 2
> #define TIOCPKT_STOP		 4
> #define TIOCPKT_START		 8
> #define TIOCPKT_NOSTOP		16
> #define TIOCPKT_DOSTOP		32
> 
> /* Compatible with asm/socket.h */
> #define FIONBIO     0x8004667e		 /* set/clear non-blocking i/o */
> 
> #define CTRL(ch)	((ch)&0x1F)
> 
> #define CNUL	0
> #define CDEL	0x0007f
> #define CESC	'\\'
> #define CINTR	CTRL('C')
> #define CQUIT	0x0001c
> #define CERASE	CDEL
> #define CKILL	CTRL('U')
> #define CEOT	CTRL('D')
> #define CEOL	0
> #define CEOL2	0
> #define CBRK	CEOL
> #define CEOF	CTRL('D')
> #define CSTART	CTRL('Q')
> #define CSTOP	CTRL('S')
> #define CSWTCH	0x0001a
> #define NSWTCH	0
> #define CSUSP	CTRL('Z')
> #define CDSUSP	CTRL('Y')
> #define CRPRNT	CTRL('R')
> #define CREPRINT	CRPRNT
> #define CFLUSH	CTRL('O')
> #define CDISCARD	CFLUSH
> #define CWERASE	CTRL('W')
> #define CLNEXT	CTRL('V')
> #define CMIN	1
> #define CTIME	0
> 
> /* iflag bits */
> #define IGNBRK	0x00001
> #define BRKINT	0x00002
> #define IGNPAR	0x00004
> #define IMAXBEL	0x00008
> #define INPCK	0x00010
> #define ISTRIP	0x00020
> #define INLCR	0x00040
> #define IGNCR	0x00080
> #define ICRNL	0x00100
> #define IXON	0x00400
> #define IXOFF	0x01000
> #define IUCLC	0x04000
> #define IXANY	0x08000
> #define PARMRK	0x10000
> #define IUTF8	0x20000
> 
> /* oflag bits */
> 
> #define OPOST	0x00001
> #define OLCUC	0x00002
> #define OCRNL	0x00004
> #define ONLCR	0x00008
> #define ONOCR	0x00010
> #define ONLRET	0x00020
> #define OFILL	0x00040
> #define CRDLY	0x00180
> #define CR0	0x00000
> #define CR1	0x00080
> #define CR2	0x00100
> #define CR3	0x00180
> #define NLDLY	0x00200
> #define NL0	0x00000
> #define NL1	0x00200
> #define BSDLY	0x00400
> #define BS0	0x00000
> #define BS1	0x00400
> #define TABDLY	0x01800
> #define TAB0	0x00000
> #define TAB1	0x00800
> #define TAB2	0x01000
> #define TAB3	0x01800
> #define XTABS	0x01800
> #define VTDLY	0x02000
> #define VT0	0x00000
> #define VT1	0x02000
> #define FFDLY	0x04000
> #define FF0	0x00000
> #define FF1	0x04000
> #define OFDEL	0x08000
> 
> /* cflag bits */
> 
> /* Baud rate values.  These must fit in speed_t, which is unsigned
>    char.  See also the extended baud rates below.  These baud rates
>    set an additional bit. */
> #define CBAUD	 0x0100f
> #define B0	 0x00000
> #define B50	 0x00001
> #define B75	 0x00002
> #define B110	 0x00003
> #define B134	 0x00004
> #define B150	 0x00005
> #define B200	 0x00006
> #define B300	 0x00007
> #define B600	 0x00008
> #define B1200	 0x00009
> #define B1800	 0x0000a
> #define B2400	 0x0000b
> #define B4800	 0x0000c
> #define B9600	 0x0000d
> #define B19200	 0x0000e
> #define B38400	 0x0000f
> 
> #define CSIZE	 0x00030
> #define CS5	 0x00000
> #define CS6	 0x00010
> #define CS7	 0x00020
> #define CS8	 0x00030
> #define CSTOPB	 0x00040
> #define CREAD	 0x00080
> #define PARENB	 0x00100
> #define PARODD	 0x00200
> #define HUPCL	 0x00400
> #define CLOCAL	 0x00800
> 
> /* Extended baud rates above 37K. */
> #define CBAUDEX	 0x0100f
> #define B57600	 0x01001
> #define B115200	 0x01002
> #define B128000	 0x01003
> #define B230400  0x01004
> #define B256000	 0x01005
> #define B460800  0x01006
> #define B500000  0x01007
> #define B576000  0x01008
> #define B921600  0x01009
> #define B1000000 0x0100a
> #define B1152000 0x0100b
> #define B1500000 0x0100c
> #define B2000000 0x0100d
> #define B2500000 0x0100e
> #define B3000000 0x0100f
> 
> #define CRTSXOFF 0x04000
> #define CRTSCTS	 0x08000
> #define CMSPAR	 0x40000000 /* Mark or space (stick) parity.  */
> 
> /* lflag bits */
> #define ISIG	0x0001
> #define ICANON	0x0002
> #define ECHO	0x0004
> #define ECHOE	0x0008
> #define ECHOK	0x0010
> #define ECHONL	0x0020
> #define NOFLSH	0x0040
> #define TOSTOP	0x0080
> #define IEXTEN	0x0100
> #define FLUSHO	0x0200
> #define ECHOKE	0x0400
> #define ECHOCTL	0x0800
> 
> #define VDISCARD	1
> #define VEOL		2
> #define VEOL2		3
> #define VEOF		4
> #define VERASE		5
> #define VINTR		6
> #define VKILL		7
> #define VLNEXT		8
> #define VMIN		9
> #define VQUIT		10
> #define VREPRINT	11
> #define VSTART		12
> #define VSTOP		13
> #define VSUSP		14
> #define VSWTC		15
> #define VTIME		16
> #define VWERASE	17
> 
> #define NCCS		18
> 
> /* Compare a character C to a value VAL from the `c_cc' array in a
>    `struct termios'.  If VAL is _POSIX_VDISABLE, no character can match it.  */
> #define CCEQ(val, c)	((c) == (val) && (val) != _POSIX_VDISABLE)
> 
> #define TTYDEF_IFLAG	(BRKINT	| ICRNL	| IMAXBEL | IXON | IXANY)
> #define TTYDEF_OFLAG	(OPOST | ONLCR)
> #define TTYDEF_LFLAG	(ICANON | ISIG | IEXTEN | ECHO | ECHOE | ECHOKE | ECHOCTL)
> #define TTYDEF_CFLAG	(CREAD | CS8 | HUPCL)
> #define TTYDEF_SPEED	(B9600)
> 
> typedef unsigned char cc_t;
> typedef unsigned int  tcflag_t;
> typedef unsigned int  speed_t;
> typedef unsigned short otcflag_t;
> typedef unsigned char ospeed_t;
> 
> struct __oldtermios
> {
>   otcflag_t	c_iflag;
>   otcflag_t	c_oflag;
>   otcflag_t	c_cflag;
>   otcflag_t	c_lflag;
>   char		c_line;
>   cc_t		c_cc[NCCS];
>   ospeed_t	c_ispeed;
>   ospeed_t	c_ospeed;
> };
> 
> struct termios
> {
>   tcflag_t	c_iflag;
>   tcflag_t	c_oflag;
>   tcflag_t	c_cflag;
>   tcflag_t	c_lflag;
>   char		c_line;
>   cc_t		c_cc[NCCS];
>   speed_t	c_ispeed;
>   speed_t	c_ospeed;
> };
> 
> #define termio termios
> 
> #ifdef __cplusplus
> extern "C" {
> #endif
> 
> int tcgetattr (int, struct termios *);
> int tcsetattr (int, int, const struct termios *);
> int tcsendbreak (int, int);
> int tcdrain (int);
> int tcflush (int, int);
> int tcflow (int, int);
> pid_t tcgetsid (int);
> void cfmakeraw (struct termios *);
> speed_t cfgetispeed(const struct termios *);
> speed_t cfgetospeed(const struct termios *);
> int cfsetispeed (struct termios *, speed_t);
> int cfsetospeed (struct termios *, speed_t);
> int cfsetspeed (struct termios *, speed_t);
> int tcgetwinsize(int fd, struct winsize *winsz);
> int tcsetwinsize(int fd, const struct winsize *winsz);
> 
> #ifdef __cplusplus
> }
> #endif
> 
> #ifndef __cplusplus
> #define cfgetispeed(tp)		((tp)->c_ispeed)
> #define cfgetospeed(tp)		((tp)->c_ospeed)
> #endif
> 
> /* Extra stuff to make porting stuff easier.  */
> struct winsize
> {
>   unsigned short ws_row, ws_col;
>   unsigned short ws_xpixel, ws_ypixel;
> };
> 
> #define TIOCGWINSZ (('T' << 8) | 1)
> #define TIOCSWINSZ (('T' << 8) | 2)
> #define TIOCLINUX  (('T' << 8) | 3)
> #define TIOCGPGRP  (('T' << 8) | 0xf)
> #define TIOCSPGRP  (('T' << 8) | 0x10)
> 
> #endif	/* _SYS_TERMIOS_H */


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


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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019