Skip to content

Commit cd5b91f

Browse files
committed
configure.ac: detect unusable termio operations
Some termio operations are not actually usable on some architectures. For example, the TCGETA, TCSETA, TCSETAF and TCSETAW are defined with a reference to "struct termio" on alpha, hppa and sparc64, but "struct termio" is no longer defined since glibc 2.42, causing a build failure. Instead of using those operations as soon as they are defined, this commit checks more carefully that they are actually usable. This is done using a new m4 macro PY_CHECK_IOCTL. Signed-off-by: Thomas Petazzoni <[email protected]>
1 parent 58e1c7a commit cd5b91f

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

Modules/termios.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ static struct constant {
11161116
#ifdef TCFLSH
11171117
{"TCFLSH", TCFLSH},
11181118
#endif
1119-
#ifdef TCGETA
1119+
#if defined(HAVE_TCGETA)
11201120
{"TCGETA", TCGETA},
11211121
#endif
11221122
#ifdef TCGETS
@@ -1128,13 +1128,13 @@ static struct constant {
11281128
#ifdef TCSBRKP
11291129
{"TCSBRKP", TCSBRKP},
11301130
#endif
1131-
#ifdef TCSETA
1131+
#if defined(HAVE_TCSETA)
11321132
{"TCSETA", TCSETA},
11331133
#endif
1134-
#ifdef TCSETAF
1134+
#if defined(HAVE_TCSETAF)
11351135
{"TCSETAF", TCSETAF},
11361136
#endif
1137-
#ifdef TCSETAW
1137+
#if defined(HAVE_TCSETAW)
11381138
{"TCSETAW", TCSETAW},
11391139
#endif
11401140
#ifdef TCSETS

configure.ac

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,26 @@ AC_DEFUN([PY_CHECK_EMSCRIPTEN_PORT], [
9595
AS_VAR_POPDEF([py_libs])
9696
])
9797

98+
dnl PY_CHECK_IOCTL(IOCTL_SYMBOL)
99+
AC_DEFUN([PY_CHECK_IOCTL],
100+
[
101+
AC_MSG_CHECKING([for $1])
102+
AC_COMPILE_IFELSE(
103+
[AC_LANG_PROGRAM(
104+
[[#include <sys/ioctl.h>]],
105+
[[
106+
/* Test whether $1 is declared */
107+
long val = $1;
108+
return 0;
109+
]]
110+
)],
111+
[AC_MSG_RESULT([yes])
112+
AC_DEFINE([HAVE_$1], [1],
113+
[Define this if $1 termio operation is usable])],
114+
[AC_MSG_RESULT([no])]
115+
)
116+
])
117+
98118
AC_SUBST([BASECPPFLAGS])
99119
if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then
100120
# If we're building out-of-tree, we need to make sure the following
@@ -8245,6 +8265,12 @@ AC_SUBST([JIT_STENCILS_H])
82458265
# substitute multiline block, must come after last PY_STDLIB_MOD()
82468266
AC_SUBST([MODULE_BLOCK])
82478267

8268+
# ioctls used by Modules/termios.c but not usable on all platforms
8269+
PY_CHECK_IOCTL([TCGETA])
8270+
PY_CHECK_IOCTL([TCSETA])
8271+
PY_CHECK_IOCTL([TCSETAF])
8272+
PY_CHECK_IOCTL([TCSETAW])
8273+
82488274
# generate output files
82498275
AC_CONFIG_FILES(m4_normalize([
82508276
Makefile.pre

0 commit comments

Comments
 (0)