From 82b98d6ededcd965d9b8088ceead135d29626deb Mon Sep 17 00:00:00 2001 From: jenglish Date: Fri, 1 Mar 2013 23:53:49 +0000 Subject: Replace broken SC_SERIAL_PORT macro with plain AC_CHECK_HEADERS tests. --- unix/configure.in | 13 ++++-- unix/tcl.m4 | 118 ---------------------------------------------------- unix/tclConfig.h.in | 9 ---- unix/tclUnixChan.c | 11 ++--- unix/tclUnixPort.h | 13 ------ 5 files changed, 15 insertions(+), 149 deletions(-) diff --git a/unix/configure.in b/unix/configure.in index 087bb05..19db579 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -259,12 +259,17 @@ if test "${TCL_THREADS}" = 1; then fi #--------------------------------------------------------------------------- -# Determine which interface to use to talk to the serial port. -# Note that #include lines must begin in leftmost column for -# some compilers to recognize them as preprocessor directives. +# Check for serial port interface. +# +# termios.h is present on all POSIX systems. +# sys/ioctl.h is almost always present, though what it contains +# is system-specific. +# sys/modem.h is needed on HP-UX. #--------------------------------------------------------------------------- -SC_SERIAL_PORT +AC_CHECK_HEADERS(termios.h) +AC_CHECK_HEADERS(sys/ioctl.h) +AC_CHECK_HEADERS(sys/modem.h) #-------------------------------------------------------------------- # Include sys/select.h if it exists and if it supplies things diff --git a/unix/tcl.m4 b/unix/tcl.m4 index b13fddd..c4b311b 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -2191,124 +2191,6 @@ dnl # preprocessing tests use only CPPFLAGS. ]) #-------------------------------------------------------------------- -# SC_SERIAL_PORT -# -# Determine which interface to use to talk to the serial port. -# Note that #include lines must begin in leftmost column for -# some compilers to recognize them as preprocessor directives, -# and some build environments have stdin not pointing at a -# pseudo-terminal (usually /dev/null instead.) -# -# Arguments: -# none -# -# Results: -# -# Defines only one of the following vars: -# HAVE_SYS_MODEM_H -# USE_TERMIOS -# USE_TERMIO -# USE_SGTTY -# -#-------------------------------------------------------------------- - -AC_DEFUN([SC_SERIAL_PORT], [ - AC_CHECK_HEADERS(sys/modem.h) - AC_CACHE_CHECK([termios vs. termio vs. sgtty], tcl_cv_api_serial, [ - AC_TRY_RUN([ -#include - -int main() { - struct termios t; - if (tcgetattr(0, &t) == 0) { - cfsetospeed(&t, 0); - t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB; - return 0; - } - return 1; -}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no) - if test $tcl_cv_api_serial = no ; then - AC_TRY_RUN([ -#include - -int main() { - struct termio t; - if (ioctl(0, TCGETA, &t) == 0) { - t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB; - return 0; - } - return 1; -}], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no) - fi - if test $tcl_cv_api_serial = no ; then - AC_TRY_RUN([ -#include - -int main() { - struct sgttyb t; - if (ioctl(0, TIOCGETP, &t) == 0) { - t.sg_ospeed = 0; - t.sg_flags |= ODDP | EVENP | RAW; - return 0; - } - return 1; -}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=no, tcl_cv_api_serial=no) - fi - if test $tcl_cv_api_serial = no ; then - AC_TRY_RUN([ -#include -#include - -int main() { - struct termios t; - if (tcgetattr(0, &t) == 0 - || errno == ENOTTY || errno == ENXIO || errno == EINVAL) { - cfsetospeed(&t, 0); - t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB; - return 0; - } - return 1; -}], tcl_cv_api_serial=termios, tcl_cv_api_serial=no, tcl_cv_api_serial=no) - fi - if test $tcl_cv_api_serial = no; then - AC_TRY_RUN([ -#include -#include - -int main() { - struct termio t; - if (ioctl(0, TCGETA, &t) == 0 - || errno == ENOTTY || errno == ENXIO || errno == EINVAL) { - t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB; - return 0; - } - return 1; - }], tcl_cv_api_serial=termio, tcl_cv_api_serial=no, tcl_cv_api_serial=no) - fi - if test $tcl_cv_api_serial = no; then - AC_TRY_RUN([ -#include -#include - -int main() { - struct sgttyb t; - if (ioctl(0, TIOCGETP, &t) == 0 - || errno == ENOTTY || errno == ENXIO || errno == EINVAL) { - t.sg_ospeed = 0; - t.sg_flags |= ODDP | EVENP | RAW; - return 0; - } - return 1; -}], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none) - fi]) - case $tcl_cv_api_serial in - termios) AC_DEFINE(USE_TERMIOS, 1, [Use the termios API for serial lines]);; - termio) AC_DEFINE(USE_TERMIO, 1, [Use the termio API for serial lines]);; - sgtty) AC_DEFINE(USE_SGTTY, 1, [Use the sgtty API for serial lines]);; - esac -]) - -#-------------------------------------------------------------------- # SC_MISSING_POSIX_HEADERS # # Supply substitutes for missing POSIX header files. Special diff --git a/unix/tclConfig.h.in b/unix/tclConfig.h.in index f171cce..8069b68 100644 --- a/unix/tclConfig.h.in +++ b/unix/tclConfig.h.in @@ -433,15 +433,6 @@ /* Should we use FIONBIO? */ #undef USE_FIONBIO -/* Use the sgtty API for serial lines */ -#undef USE_SGTTY - -/* Use the termio API for serial lines */ -#undef USE_TERMIO - -/* Use the termios API for serial lines */ -#undef USE_TERMIOS - /* Do we want to use the threaded memory allocator? */ #undef USE_THREAD_ALLOC diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index 5d11e94..fb47f6a 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -14,8 +14,10 @@ #include "tclInt.h" /* Internal definitions for Tcl. */ #include "tclIO.h" /* To get Channel type declaration. */ -#ifdef USE_TERMIOS -# define SUPPORTS_TTY +#undef SUPPORTS_TTY +#if defined(HAVE_TERMIOS_H) || defined(USE_TERMIOS) + /* [1 Mar 2013] USE_TERMIOS: temporarily left in, to be removed */ +# define SUPPORTS_TTY 1 # include # ifdef HAVE_SYS_IOCTL_H # include @@ -39,9 +41,8 @@ # if !defined(PAREXT) && defined(CMSPAR) # define PAREXT CMSPAR # endif /* !PAREXT&&CMSPAR */ -#else /* !USE_TERMIOS */ -# undef SUPPORTS_TTY -#endif /* !USE_TERMIOS */ + +#endif /* HAVE_TERMIOS_H */ /* * Helper macros to make parts of this file clearer. The macros do exactly diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index 59a35ba..636c760 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -578,19 +578,6 @@ extern char ** environ; /* *--------------------------------------------------------------------------- - * The termios configure test program relies on the configure script being run - * from a terminal, which is not the case e.g., when configuring from Xcode. - * Since termios is known to be present on all Mac OS X releases since 10.0, - * override the configure defines for serial API here. [Bug 497147] - *--------------------------------------------------------------------------- - */ - -# define USE_TERMIOS 1 -# undef USE_TERMIO -# undef USE_SGTTY - -/* - *--------------------------------------------------------------------------- * Include AvailabilityMacros.h here (when available) to ensure any symbolic * MAC_OS_X_VERSION_* constants passed on the command line are translated. *--------------------------------------------------------------------------- -- cgit v0.12