Ticket UUID: | 1901828 | |||
Title: | Unix portability - cruft removal | |||
Type: | Patch | Version: | None | |
Submitter: | jenglish | Created on: | 2008-02-26 02:37:48 | |
Subsystem: | 52. Portability Support | Assigned To: | jenglish | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2008-02-27 10:36:11 | |
Resolution: | Accepted | Closed By: | jenglish | |
Closed on: | 2008-02-27 03:36:11 | |||
Description: |
Attached patch (forthcoming) removes some long-dead #ifdeffery related to pre-POSIX cross-Unix portability. Archaeological notes to follow. | |||
User Comments: |
jenglish added on 2008-02-27 10:36:11:
Logged In: YES user_id=68433 Originator: YES Patch tested locally on the oldest Unices I could find (IRIX 6.5, AIX 4.1), and on a modern one (Debian sarge). Committing. jenglish added on 2008-02-27 03:43:27: Logged In: YES user_id=68433 Originator: YES unix/tclUnixPort.h has: #ifdef NO_STDLIB_H extern double strtod(); #endif Post-numerics reform, strtod() is no longer used anywhere in the Tcl source base. This declaration can go. Related: SC_BUGGY_STRTOD autoconf macro, compat/strtod.c, and compat/fixstrod.c. This is a whole other barrel of works, to be addressed separately. jenglish added on 2008-02-27 02:31:55: File Added - 268135: tcl-tip35-mopup.patch Logged In: YES user_id=68433 Originator: YES TtyCloseProc() notes: /* * 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 */ We are well past the final 8.4 release; attached patch tcl-tip35-mopup replaces TtyCloseProc() with FileCloseProc() (since the former does nothing except call the latter), and removes TtyState.stateUpdated as suggested. TtyState.savedState is still used elsewhere and cannot be removed, nor can TtyState be merged with FileState (yet). File Added: tcl-tip35-mopup.patch jenglish added on 2008-02-27 02:23:14: File Added - 268134: tcl-no-bad-tip35-flush.patch Logged In: YES user_id=68433 Originator: YES The initial TIP#35 implementation (patch #438509, committed 2002-02-26) called tcflush() in TtyCloseProc, which discards all untransmitted data. This lead to problems (bug #525783, #525778), and a fix was committed 2002-03-05 that #ifdef'ed out the offending code (conditionalized on -DBAD_TIP35_FLUSH). However, the "discard untransmitted data" behavior was not, in fact, specified by TIP#35. Related: TIP#160 (targeted for 8.6, vote still pending) proposes a "-closemode {drain|discard}" option, and notes that "drain" is the current default. Since this code has been effectively disabled since shortly after its introduction, was not specified in TIP#35, and will be superceded by TIP#160 should that be implemented, there's no need to keep the existing BAD_TIP35_FLUSH code around. Attached patch tcl-no-bad-tip35-flush.patch can be reverted in case anyone wants it back. File Added: tcl-no-bad-tip35-flush.patch jenglish added on 2008-02-26 10:59:31: File Added - 268022: tcl-cruft-removal.patch Logged In: YES user_id=68433 Originator: YES File Added: tcl-cruft-removal.patch jenglish added on 2008-02-26 10:52:19: Logged In: YES user_id=68433 Originator: YES unix/tclUnixPort.h has: # include <sys/param.h> # ifndef CLK_TCK # ifdef HZ # define CLK_TCK HZ # else # define CLK_TCK 60 # endif # endif CLK_TCK was last used in Tcl 7.4, in Tcl_TimeCmd. From Tcl 7.5 onwards, it does not appear anywhere else in the codebase. Furthermore: according to times(2) in the glibc manpages: | The number of clock ticks per second can be obtained using |sysconf(_SC_CLK_TCK); | In POSIX-1996 the symbol CLK_TCK (defined in <time.h>) is mentioned as | obsolescent. It is obsolete now. jenglish added on 2008-02-26 10:39:07: Logged In: YES user_id=68433 Originator: YES generic/tclIOUtil.c has: #if defined(O_NDELAY) || defined(O_NONBLOCK) # ifdef O_NONBLOCK mode |= O_NONBLOCK; # else mode |= O_NDELAY; # endif #else if (interp != NULL) { Tcl_AppendResult(interp, "access mode \"", flag, "\" not supported by this system", NULL); } ckfree((char *) modeArgv); return -1; #endif However, tclUnixPort.h (included by tclPort.h, included by tclInt.h, included by tclIOUtil.c) has: /* * NeXT doesn't define O_NONBLOCK, so #define it here if necessary. */ #ifndef O_NONBLOCK # define O_NONBLOCK 0x80 #endif So O_NONBLOCK is always defined, and the other #if branches are never used. History: The sequence: | #ifdef O_NONBLOCK | mode |= O_NONBLOCK; | #else | mode |= O_NDELAY; | #endif was present in Tcl 7.0 (Sep 1993) through Tcl 7.4 (Jun 1995). I did not check any earlier than Tcl 7.0. An #else clause was introduced in Tcl 7.5 (Apr 1996) to account for the possibility that neither O_NONBLOCK nor O_NDELAY are defined: | #if defined(O_NDELAY) || defined(O_NONBLOCK) ... {as above} ... | #else | if (interp != (Tcl_Interp *) NULL) { | Tcl_AppendResult(interp, "access mode \"", flag, | "\" not supported by this system", (char *) NULL); | } | ckfree((char *) modeArgv); | return -1; | #endif The O_NONBLOCK definition in unix/tclUnixPort.h was added in the same release; so it would appear that the 'access mode "NONBLOCK" not supported by this system' message has been effectively #ifdef'ed out since its introduction. jenglish added on 2008-02-26 09:43:03: Logged In: YES user_id=68433 Originator: YES unix/tclUnixPort.h has: -/* - * 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 symbol NBIO_FLAG does not appear anywhere else in the Tcl codebase. This bit of #ifdeffery first made its appearance in Tcl 7.5. NBIO_FLAG was defined, but not used anywhere in that release either. |