From 1b53611f89790af211f2811b6eb6acb094e04a00 Mon Sep 17 00:00:00 2001 From: jenglish Date: Wed, 27 Feb 2008 03:35:47 +0000 Subject: Remove dead/unused portability-related #defines and unused conditional code. See SF#1901828 for discussion and archaeological notes. --- ChangeLog | 6 +++ generic/tclIOUtil.c | 9 +--- unix/tclUnixChan.c | 127 +++------------------------------------------------- unix/tclUnixPort.h | 38 +--------------- 4 files changed, 15 insertions(+), 165 deletions(-) diff --git a/ChangeLog b/ChangeLog index e483231..8bcaa5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-02-22 Joe English + + * generic/tclIOUtil.c, unix/tclUnixPort.h, unix/tclUnixChan.c: + Remove dead/unused portability-related #defines and + unused conditional code. See [Patch 1901828] for discussion. + 2008-02-27 Kevin B. Kenny * doc/clock.n: Corrected minor indentation gaffe in the diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index c996b1f..745ba6b 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -17,7 +17,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIOUtil.c,v 1.150 2008/01/23 21:21:31 dgp Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.151 2008/02/27 03:35:49 jenglish Exp $ */ #include "tclInt.h" @@ -1670,13 +1670,8 @@ TclGetOpenModeEx( #endif } else if ((c == 'N') && (strcmp(flag, "NONBLOCK") == 0)) { -#if defined(O_NDELAY) || defined(O_NONBLOCK) -# ifdef O_NONBLOCK +#ifdef O_NONBLOCK mode |= O_NONBLOCK; -# else - mode |= O_NDELAY; -# endif - #else if (interp != NULL) { Tcl_AppendResult(interp, "access mode \"", flag, diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index 7e3c507..e0f7761 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixChan.c,v 1.89 2007/12/13 15:28:42 dgp Exp $ + * RCS: @(#) $Id: tclUnixChan.c,v 1.90 2008/02/27 03:35:50 jenglish Exp $ */ #include "tclInt.h" /* Internal definitions for Tcl. */ @@ -65,22 +65,6 @@ # define GETCONTROL(fd, intPtr) ioctl((fd), TIOCMGET, (intPtr)) # define SETCONTROL(fd, intPtr) ioctl((fd), TIOCMSET, (intPtr)) - /* - * TIP #35 introduced a different on exit flush/close behavior that does - * not work correctly with standard channels on all systems. The problem - * is tcflush throws away waiting channel data. This may be necessary for - * true serial channels that may block, but isn't correct in the standard - * case. This might be replaced with tcdrain instead, but that can block. - * For now, we revert to making this do nothing, and TtyOutputProc being - * the same old FileOutputProc. - hobbs [Bug #525783] - */ - -# define BAD_TIP35_FLUSH 0 -# if BAD_TIP35_FLUSH -# define TTYFLUSH(fd) tcflush((fd), TCIOFLUSH); -# else -# define TTYFLUSH(fd) -# endif /* BAD_TIP35_FLUSH */ # ifdef FIONREAD # define GETREADQUEUE(fd, int) ioctl((fd), FIONREAD, &(int)) # elif defined(FIORDCHK) @@ -158,8 +142,6 @@ typedef struct FileState { typedef struct TtyState { FileState fs; /* Per-instance state of the file descriptor. * Must be the first field. */ - int stateUpdated; /* Flag to say if the state has been modified - * and needs resetting. */ IOSTATE savedState; /* Initial state of device. Used to reset * state when device closed. */ } TtyState; @@ -270,8 +252,6 @@ static int TcpOutputProc(ClientData instanceData, const char *buf, int toWrite, int *errorCode); static void TcpWatchProc(ClientData instanceData, int mask); #ifdef SUPPORTS_TTY -static int TtyCloseProc(ClientData instanceData, - Tcl_Interp *interp); static void TtyGetAttributes(int fd, TtyAttrs *ttyPtr); static int TtyGetOptionProc(ClientData instanceData, Tcl_Interp *interp, const char *optionName, @@ -282,10 +262,6 @@ static unsigned long TtyGetSpeed(int baud); #endif /* DIRECT_BAUD */ static FileState * TtyInit(int fd, int initialize); static void TtyModemStatusStr(int status, Tcl_DString *dsPtr); -#if BAD_TIP35_FLUSH -static int TtyOutputProc(ClientData instanceData, - const char *buf, int toWrite, int *errorCode); -#endif /* BAD_TIP35_FLUSH */ static int TtyParseMode(Tcl_Interp *interp, const char *mode, int *speedPtr, int *parityPtr, int *dataPtr, int *stopPtr); @@ -331,13 +307,9 @@ static Tcl_ChannelType fileChannelType = { static Tcl_ChannelType ttyChannelType = { "tty", /* Type name. */ TCL_CHANNEL_VERSION_5, /* v5 channel */ - TtyCloseProc, /* Close proc. */ + FileCloseProc, /* Close proc. */ FileInputProc, /* Input proc. */ -#if BAD_TIP35_FLUSH - TtyOutputProc, /* Output proc. */ -#else /* !BAD_TIP35_FLUSH */ FileOutputProc, /* Output proc. */ -#endif /* BAD_TIP35_FLUSH */ NULL, /* Seek proc. */ TtySetOptionProc, /* Set option proc. */ TtyGetOptionProc, /* Get option proc. */ @@ -738,94 +710,6 @@ FileGetHandleProc( } #ifdef SUPPORTS_TTY -/* - *---------------------------------------------------------------------- - * - * TtyCloseProc -- - * - * This function is called from the generic IO level to perform - * channel-type-specific cleanup when a tty based channel is closed. - * - * Results: - * 0 if successful, errno if failed. - * - * Side effects: - * Closes the device of the channel. - * - *---------------------------------------------------------------------- - */ - -static int -TtyCloseProc( - ClientData instanceData, /* Tty state. */ - Tcl_Interp *interp) /* For error reporting - unused. */ -{ -#if BAD_TIP35_FLUSH - TtyState *ttyPtr = (TtyState *) instanceData; -#endif /* BAD_TIP35_FLUSH */ - -#ifdef TTYFLUSH - TTYFLUSH(ttyPtr->fs.fd); -#endif /* TTYFLUSH */ - -#if 0 - /* - * TIP#35 agreed to remove the unsave so that TCL could be used as a - * simple stty. It would be cleaner to remove all the stuff related to - * TtyState.stateUpdated - * TtyState.savedState - * Then the structure TtyState would be the same as FileState. IMO this - * cleanup could better be done for the final 8.4 release after nobody - * complained about the missing unsave. - schroedter - */ - if (ttyPtr->stateUpdated) { - SETIOSTATE(ttyPtr->fs.fd, &ttyPtr->savedState); - } -#endif - - return FileCloseProc(instanceData, interp); -} - -/* - *---------------------------------------------------------------------- - * - * TtyOutputProc-- - * - * This function is invoked from the generic IO level to write output to - * a TTY channel. - * - * Results: - * The number of bytes written is returned or -1 on error. An output - * argument contains a POSIX error code if an error occurred, or zero. - * - * Side effects: - * Writes output on the output device of the channel if the channel is - * not designated to be closed. - * - *---------------------------------------------------------------------- - */ - -#if BAD_TIP35_FLUSH -static int -TtyOutputProc( - ClientData instanceData, /* File state. */ - const char *buf, /* The data buffer. */ - int toWrite, /* How many bytes to write? */ - int *errorCodePtr) /* Where to store error code. */ -{ - if (TclInExit()) { - /* - * Do not write data during Tcl exit. Serial port may block preventing - * Tcl from exit. - */ - - return toWrite; - } - - return FileOutputProc(instanceData, buf, toWrite, errorCodePtr); -} -#endif /* BAD_TIP35_FLUSH */ - #ifdef USE_TERMIOS /* *---------------------------------------------------------------------- @@ -912,7 +796,6 @@ TtySetOptionProc( */ TtySetAttributes(fsPtr->fd, &tty); - ((TtyState *) fsPtr)->stateUpdated = 1; return TCL_OK; } @@ -1704,10 +1587,10 @@ TtyInit( int initialize) { TtyState *ttyPtr; + int stateUpdated = 0; ttyPtr = (TtyState *) ckalloc((unsigned) sizeof(TtyState)); GETIOSTATE(fd, &ttyPtr->savedState); - ttyPtr->stateUpdated = 0; if (initialize) { IOSTATE iostate = ttyPtr->savedState; @@ -1718,7 +1601,7 @@ TtyInit( iostate.c_cflag & CREAD || iostate.c_cc[VMIN] != 1 || iostate.c_cc[VTIME] != 0) { - ttyPtr->stateUpdated = 1; + stateUpdated = 1; } iostate.c_iflag = IGNBRK; iostate.c_oflag = 0; @@ -1741,7 +1624,7 @@ TtyInit( * Only update if we're changing anything to avoid possible blocking. */ - if (ttyPtr->stateUpdated) { + if (stateUpdated) { SETIOSTATE(fd, &iostate); } } diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index 4ee2ece..dc0fb40 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -19,7 +19,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixPort.h,v 1.61 2007/12/13 15:28:42 dgp Exp $ + * RCS: @(#) $Id: tclUnixPort.h,v 1.62 2008/02/27 03:35:50 jenglish Exp $ */ #ifndef _TCLUNIXPORT @@ -174,18 +174,6 @@ typedef off_t Tcl_SeekOffset; #endif /* - * HPUX needs the flag O_NONBLOCK to get the right non-blocking I/O - * semantics, while most other systems need O_NDELAY. Define the - * constant NBIO_FLAG to be one of these - */ - -#ifdef HPUX -# define NBIO_FLAG O_NONBLOCK -#else -# define NBIO_FLAG O_NDELAY -#endif - -/* * The type of the status returned by wait varies from UNIX system * to UNIX system. The macro below defines it: */ @@ -258,21 +246,11 @@ typedef off_t Tcl_SeekOffset; /* * The stuff below is needed by the "time" command. If this system has no - * gettimeofday call, then must use times and the CLK_TCK #define (from - * sys/param.h) to compute elapsed time. Unfortunately, some systems only - * have HZ and no CLK_TCK, and some might not even have HZ. + * gettimeofday call, then must use times() instead. */ #ifdef NO_GETTOD # include -# include -# ifndef CLK_TCK -# ifdef HZ -# define CLK_TCK HZ -# else -# define CLK_TCK 60 -# endif -# endif #else # ifdef HAVE_BSDGETTIMEOFDAY # define gettimeofday BSDgettimeofday @@ -489,18 +467,6 @@ extern char **environ; #endif /* - * At present (12/91) not all stdlib.h implementations declare strtod. - * The declaration below is here to ensure that it's declared, so that - * the compiler won't take the default approach of assuming it returns - * an int. There's no ANSI prototype for it because there would end - * up being too many conflicts with slightly-different prototypes. - */ - -#ifdef NO_STDLIB_H -extern double strtod(); -#endif - -/* * There is no platform-specific panic routine for Unix in the Tcl internals. */ -- cgit v0.12