Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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_CONSTANT.
8 changes: 4 additions & 4 deletions Modules/termios.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ static struct constant {
#ifdef TCFLSH
{"TCFLSH", TCFLSH},
#endif
#ifdef TCGETA
#ifdef HAVE_TCGETA
{"TCGETA", TCGETA},
#endif
#ifdef TCGETS
Expand All @@ -1128,13 +1128,13 @@ static struct constant {
#ifdef TCSBRKP
{"TCSBRKP", TCSBRKP},
#endif
#ifdef TCSETA
#ifdef HAVE_TCSETA
{"TCSETA", TCSETA},
#endif
#ifdef TCSETAF
#ifdef HAVE_TCSETAF
{"TCSETAF", TCSETAF},
#endif
#ifdef TCSETAW
#ifdef HAVE_TCSETAW
{"TCSETAW", TCSETAW},
#endif
#ifdef TCSETS
Expand Down
116 changes: 116 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ AC_DEFUN([PY_CHECK_EMSCRIPTEN_PORT], [
AS_VAR_POPDEF([py_libs])
])

dnl PY_CHECK_CONSTANT(TYPE, CONSTANT, [INCLUDES])
dnl Checks whether the constant exists and is actually usable (unlike
dnl AC_CHECK_DECL that only checks if the constant exists)
AC_DEFUN([PY_CHECK_CONSTANT], [
AC_MSG_CHECKING([for $2])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$3], [[$1 val = $2;]])],
[AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_$2], [1],
[Defined if $2 is usable])],
[AC_MSG_RESULT([no])]
)])

AC_SUBST([BASECPPFLAGS])
if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then
# If we're building out-of-tree, we need to make sure the following
Expand Down Expand Up @@ -8245,6 +8257,12 @@ AC_SUBST([JIT_STENCILS_H])
# substitute multiline block, must come after last PY_STDLIB_MOD()
AC_SUBST([MODULE_BLOCK])

# ioctls used by Modules/termios.c but not usable on all platforms
PY_CHECK_CONSTANT([long], [TCGETA], [#include <sys/ioctl.h>])
PY_CHECK_CONSTANT([long], [TCSETA], [#include <sys/ioctl.h>])
PY_CHECK_CONSTANT([long], [TCSETAF], [#include <sys/ioctl.h>])
PY_CHECK_CONSTANT([long], [TCSETAW], [#include <sys/ioctl.h>])

# generate output files
AC_CONFIG_FILES(m4_normalize([
Makefile.pre
Expand Down
12 changes: 12 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1524,9 +1524,21 @@
/* Define to 1 if you have the <sys/xattr.h> header file. */
#undef HAVE_SYS_XATTR_H

/* Defined if TCGETA is usable */
#undef HAVE_TCGETA

/* Define to 1 if you have the 'tcgetpgrp' function. */
#undef HAVE_TCGETPGRP

/* Defined if TCSETA is usable */
#undef HAVE_TCSETA

/* Defined if TCSETAF is usable */
#undef HAVE_TCSETAF

/* Defined if TCSETAW is usable */
#undef HAVE_TCSETAW

/* Define to 1 if you have the 'tcsetpgrp' function. */
#undef HAVE_TCSETPGRP

Expand Down
Loading