diff options
author | das <das> | 2003-02-21 20:11:35 (GMT) |
---|---|---|
committer | das <das> | 2003-02-21 20:11:35 (GMT) |
commit | 73126af737ee9804ffed26a31c476a9fd50074c2 (patch) | |
tree | bf956f89f4c77156fcba4fd95ab31213a6996894 | |
parent | aa03f845d607abd4fd81d2432729f2d98a161df2 (diff) | |
download | tcl-73126af737ee9804ffed26a31c476a9fd50074c2.zip tcl-73126af737ee9804ffed26a31c476a9fd50074c2.tar.gz tcl-73126af737ee9804ffed26a31c476a9fd50074c2.tar.bz2 |
* mac/tclMacChan.c (TclpCutFileChannel, TclpSpliceFileChannel):
Implemented missing cut and splice procs for file channels.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | mac/tclMacChan.c | 93 |
2 files changed, 97 insertions, 1 deletions
@@ -1,3 +1,8 @@ +2003-02-21 Daniel Steffen <das@users.sourceforge.net> + + * mac/tclMacChan.c (TclpCutFileChannel, TclpSpliceFileChannel): + Implemented missing cut and splice procs for file channels. + 2003-02-21 Don Porter <dgp@users.sourceforge.net> * library/package.tcl (tclPkgUnknown): Minor performance tweaks diff --git a/mac/tclMacChan.c b/mac/tclMacChan.c index ea261e9..414309e 100644 --- a/mac/tclMacChan.c +++ b/mac/tclMacChan.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclMacChan.c,v 1.19 2002/11/07 02:13:36 mdejong Exp $ + * RCS: @(#) $Id: tclMacChan.c,v 1.20 2003/02/21 20:11:35 das Exp $ */ #include "tclInt.h" @@ -24,6 +24,7 @@ #include <FSpCompat.h> #include <MoreFiles.h> #include <MoreFilesExtras.h> +#include "tclIO.h" #ifdef __MSL__ #include <unix.mac.h> @@ -1224,3 +1225,93 @@ CommonWatch( } } } + +/* + *---------------------------------------------------------------------- + * + * TclpCutFileChannel -- + * + * Remove any thread local refs to this channel. See + * Tcl_CutChannel for more info. + * + * Results: + * None. + * + * Side effects: + * Changes thread local list of valid channels. + * + *---------------------------------------------------------------------- + */ + +void +TclpCutFileChannel(chan) + Tcl_Channel chan; /* The channel being removed. Must + * not be referenced in any + * interpreter. */ +{ + ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); + Channel *chanPtr = (Channel *) chan; + FileState *infoPtr; + FileState **nextPtrPtr; + int removed = 0; + + if (chanPtr->typePtr != &fileChannelType) + return; + + infoPtr = (FileState *) chanPtr->instanceData; + + for (nextPtrPtr = &(tsdPtr->firstFilePtr); (*nextPtrPtr) != NULL; + nextPtrPtr = &((*nextPtrPtr)->nextPtr)) { + if ((*nextPtrPtr) == infoPtr) { + (*nextPtrPtr) = infoPtr->nextPtr; + removed = 1; + break; + } + } + + /* + * This could happen if the channel was created in one thread + * and then moved to another without updating the thread + * local data in each thread. + */ + + if (!removed) + panic("file info ptr not on thread channel list"); + +} + +/* + *---------------------------------------------------------------------- + * + * TclpSpliceFileChannel -- + * + * Insert thread local ref for this channel. + * Tcl_SpliceChannel for more info. + * + * Results: + * None. + * + * Side effects: + * Changes thread local list of valid channels. + * + *---------------------------------------------------------------------- + */ + +void +TclpSpliceFileChannel(chan) + Tcl_Channel chan; /* The channel being removed. Must + * not be referenced in any + * interpreter. */ +{ + ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); + Channel *chanPtr = (Channel *) chan; + FileState *infoPtr; + + if (chanPtr->typePtr != &fileChannelType) + return; + + infoPtr = (FileState *) chanPtr->instanceData; + + infoPtr->nextPtr = tsdPtr->firstFilePtr; + tsdPtr->firstFilePtr = infoPtr; +} |