utils/magsgtty.h: detect termio/ioctl headers

Linux is not based on BSD and this file appears to exist to manage
historic BSD conventions concerning termios.
This commit is contained in:
Darryl L. Miles 2024-10-16 09:38:24 +01:00 committed by R. Timothy Edwards
parent c5ebd7d3c0
commit 9f1398dfcb
2 changed files with 21 additions and 1 deletions

View File

@ -170,6 +170,15 @@ dnl Check for <sys/time.h>
AC_CHECK_HEADERS(sys/time.h)
AC_HEADER_TIME
dnl Check for <termio.h>
AC_CHECK_HEADERS(termio.h)
dnl Check for <termios.h>
AC_CHECK_HEADERS(termios.h)
dnl Check for <sys/ioctl.h>
AC_CHECK_HEADERS(sys/ioctl.h)
dnl Check for va_copy
AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy,
AC_TRY_LINK(

View File

@ -21,6 +21,7 @@
#ifndef _MAGIC__UTILS__MAGSGTTY_H
#define _MAGIC__UTILS__MAGSGTTY_H
/* maybe this can be #ifndef HAVE_TERMIO_H */
#if !defined(SYSV) && !defined(CYGWIN)
# ifdef ALPHA
@ -28,15 +29,25 @@
# undef MIN
# endif
/* unclear what platform requires this OpenBSD/FreeBSD ? */
# ifndef COMPAT_43TTY
# define COMPAT_43TTY
# endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#if defined(__OpenBSD__) || defined(EMSCRIPTEN)
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#else
/* unclear which platform(s) require <sys/ioctl_compat.h> and the structure
* of this file is such that it will try to include it by default, better
* to invert the #if and only select this on the known platforms that need
* it so that <termios.h> goes by default, which exists on MacOSX, Linux, etc..
* many possible solutions to make this work by default:
* HAVE_SYS_IOCTL_COMPAT_H ? HAVE_TERMIOS_H ? !defined(linux) at top (MaxOSX is BSD type)
*/
#include <sys/ioctl_compat.h>
#endif