aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2025-07-18 10:15:30 +0200
committerCorinna Vinschen <corinna@vinschen.de>2025-07-18 10:53:08 +0200
commit73600d68227e125af24b7de7c3fccbd4eb66ee03 (patch)
tree3bbfbd7c5914e7a44027c1bedfecb5f06e972a1e
parentae64eddce5d9902f4c13977977755462de874161 (diff)
downloadnewlib-73600d68227e125af24b7de7c3fccbd4eb66ee03.zip
newlib-73600d68227e125af24b7de7c3fccbd4eb66ee03.tar.gz
newlib-73600d68227e125af24b7de7c3fccbd4eb66ee03.tar.bz2
Cygwin: sys/termios.h: define struct winsize before using it
Long-standing bug in the sys/termios.h file which, for some reason, has never been encountered before. STC: #include <sys/termios.h> int main() { struct winsize win; tcgetwinsize (0, &win); } Result with gcc 12.4.0: termios-bug.c: In function ‘main’: termios-bug.c:7:20: warning: passing argument 2 of ‘tcgetwinsize’ from incompatible pointer type [-Wincompatible-pointer-types] 7 | tcgetwinsize (0, &win); | ^~~~ | | | struct winsize * In file included from termios-bug.c:1: /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 warning apparently becomes an error with C23. The reason is that struct winsize is defined in sys/termios.h after using it as argument type in function declarations. From the compil;er perspective it's now a different type , regardless of having the same name. Move declaration of struct winsize up so it's defined before being used. Reported-by: Zachary Santer <zsanter@gmail.com> Suggested-by: Zachary Santer <zsanter@gmail.com> Addresses: https://cygwin.com/pipermail/cygwin/2025-July/258474.html Fixes: 1fd5e000ace55 ("import winsup-2000-02-17 snapshot") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/include/sys/termios.h13
-rw-r--r--winsup/cygwin/release/3.6.55
2 files changed, 10 insertions, 8 deletions
diff --git a/winsup/cygwin/include/sys/termios.h b/winsup/cygwin/include/sys/termios.h
index 4c03042..6cd6407 100644
--- a/winsup/cygwin/include/sys/termios.h
+++ b/winsup/cygwin/include/sys/termios.h
@@ -283,6 +283,12 @@ struct termios
speed_t c_ospeed;
};
+struct winsize
+{
+ unsigned short ws_row, ws_col;
+ unsigned short ws_xpixel, ws_ypixel;
+};
+
#define termio termios
#ifdef __cplusplus
@@ -314,13 +320,6 @@ int tcsetwinsize(int fd, const struct winsize *winsz);
#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)
diff --git a/winsup/cygwin/release/3.6.5 b/winsup/cygwin/release/3.6.5
index 471a12a..402c8ab 100644
--- a/winsup/cygwin/release/3.6.5
+++ b/winsup/cygwin/release/3.6.5
@@ -1,4 +1,7 @@
Fixes:
------
-Fix two minor bugs in clock and POSIX timer handling.
+- Fix two minor bugs in clock and POSIX timer handling.
+
+- Fix an ordering problem in sys/termios.h.
+ Addresses: https://cygwin.com/pipermail/cygwin/2025-July/258474.html