+2024-08-12 Collin Funk <collin.funk1@gmail.com>
+
+ termios: Define struct winsize on all platforms.
+ * doc/posix-headers/termios.texi (termios.h): Mention struct winsize is
+ defined in <sys/ioctl.h> on glibc.
+ * lib/termios.in.h (struct winsize): Define or include.
+ * m4/termios_h.m4 (gl_TERMIOS_H): Check for a definition of struct
+ winsize.
+ * modules/termios (Makefile.am): Replace AC_SUBST variables.
+
2024-08-12 Bruno Haible <bruno@clisp.org>
errno tests: Avoid test failure on Haiku.
Portability problems not fixed by Gnulib:
@itemize
@item
-The types @code{struct termios}, @code{cc_t}, @code{speed_t}, @code{tcflag_t}
-are not defined on some platforms:
+The types @code{struct termios}, @code{struct winsize}, @code{cc_t},
+@code{speed_t}, @code{tcflag_t} are not defined on some platforms:
mingw, MSVC 14.
+
+@item
+@code{struct winsize} is defined in @code{sys/ioctl.h} on some
+platforms:
+glibc
+
@end itemize
# termios_h.m4
-# serial 7
+# serial 8
dnl Copyright (C) 2010-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
HAVE_TERMIOS_H=0
fi
+ if test $ac_cv_header_termios_h = yes; then
+ AC_CACHE_CHECK([for struct winsize in <termios.h>],
+ [gl_cv_struct_winsize_in_termios_h],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <termios.h>
+ ]],
+ [[static struct winsize x; x.ws_row = x.ws_col;]])],
+ [gl_cv_struct_winsize_in_termios_h=yes],
+ [gl_cv_struct_winsize_in_termios_h=no])
+ ])
+ if test $gl_cv_struct_winsize_in_termios_h = no; then
+ AC_CHECK_HEADERS_ONCE([sys/ioctl.h])
+ if test $ac_cv_header_sys_ioctl_h = yes; then
+ AC_CACHE_CHECK([for struct winsize in <sys/ioctl.h>],
+ [gl_cv_struct_winsize_in_sys_ioctl_h],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <sys/ioctl.h>
+ ]],
+ [[static struct winsize x; x.ws_row = x.ws_col;]])],
+ [gl_cv_struct_winsize_in_sys_ioctl_h=yes],
+ [gl_cv_struct_winsize_in_sys_ioctl_h=no])
+ ])
+ fi
+ fi
+ fi
+
+ TERMIOS_H_DEFINES_STRUCT_WINSIZE=0
+ SYS_IOCTL_H_DEFINES_STRUCT_WINSIZE=0
+ if test "$gl_cv_struct_winsize_in_termios_h" != yes \
+ || test "$gl_cv_struct_winsize_in_sys_ioctl_h" != yes; then
+ if test "$gl_cv_struct_winsize_in_termios_h" = yes; then
+ TERMIOS_H_DEFINES_STRUCT_WINSIZE=1
+ elif test "$gl_cv_struct_winsize_in_sys_ioctl_h" = yes; then
+ SYS_IOCTL_H_DEFINES_STRUCT_WINSIZE=1
+ fi
+ fi
+
dnl Ensure the type pid_t gets defined.
AC_REQUIRE([AC_TYPE_PID_T])
dnl guaranteed by C89.
gl_WARN_ON_USE_PREPARE([[#include <termios.h>]],
[tcgetsid])
+
+ AC_SUBST([TERMIOS_H_DEFINES_STRUCT_WINSIZE])
+ AC_SUBST([SYS_IOCTL_H_DEFINES_STRUCT_WINSIZE])
])
# gl_TERMIOS_MODULE_INDICATOR([modulename])
-e 's/@''GNULIB_TCGETSID''@/$(GNULIB_TCGETSID)/g' \
-e 's|@''HAVE_DECL_TCGETSID''@|$(HAVE_DECL_TCGETSID)|g' \
-e 's|@''HAVE_TERMIOS_H''@|$(HAVE_TERMIOS_H)|g' \
+ -e 's|@''TERMIOS_H_DEFINES_STRUCT_WINSIZE''@|$(TERMIOS_H_DEFINES_STRUCT_WINSIZE)|g' \
+ -e 's|@''SYS_IOCTL_H_DEFINES_STRUCT_WINSIZE''@|$(SYS_IOCTL_H_DEFINES_STRUCT_WINSIZE)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
$(srcdir)/termios.in.h > $@-t