diff options
author | dgp <dgp@users.sourceforge.net> | 2020-02-28 20:11:28 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2020-02-28 20:11:28 (GMT) |
commit | 71287e013ec1019520d1d065534809f96ddc2172 (patch) | |
tree | 29540a29820e587ce434991ca7ece49c037e9bc0 /generic/tclIORChan.c | |
parent | 1d5869d815883fe8fc5faf3769423feb05c5ad1c (diff) | |
parent | f30e9cfd651ee306da5a43deb26e4260132bec6b (diff) | |
download | tcl-71287e013ec1019520d1d065534809f96ddc2172.zip tcl-71287e013ec1019520d1d065534809f96ddc2172.tar.gz tcl-71287e013ec1019520d1d065534809f96ddc2172.tar.bz2 |
merge trunk
Diffstat (limited to 'generic/tclIORChan.c')
-rw-r--r-- | generic/tclIORChan.c | 115 |
1 files changed, 52 insertions, 63 deletions
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index 5a63a23..c250ef7 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -32,7 +32,7 @@ */ static int ReflectClose(ClientData clientData, - Tcl_Interp *interp); + Tcl_Interp *interp, int flags); static int ReflectInput(ClientData clientData, char *buf, int toRead, int *errorCodePtr); static int ReflectOutput(ClientData clientData, const char *buf, @@ -46,8 +46,6 @@ static int ReflectEventDelete(Tcl_Event *ev, ClientData cd); #endif static Tcl_WideInt ReflectSeekWide(ClientData clientData, Tcl_WideInt offset, int mode, int *errorCodePtr); -static int ReflectSeek(ClientData clientData, long offset, - int mode, int *errorCodePtr); static int ReflectGetOption(ClientData clientData, Tcl_Interp *interp, const char *optionName, Tcl_DString *dsPtr); @@ -65,15 +63,15 @@ static void TimerRunWrite(ClientData clientData); static const Tcl_ChannelType tclRChannelType = { "tclrchannel", /* Type name. */ TCL_CHANNEL_VERSION_5, /* v5 channel */ - ReflectClose, /* Close channel, clean instance data */ + NULL, /* Close channel, clean instance data */ ReflectInput, /* Handle read request */ ReflectOutput, /* Handle write request */ - ReflectSeek, /* Move location of access point. NULL'able */ + NULL, ReflectSetOption, /* Set options. NULL'able */ ReflectGetOption, /* Get options. NULL'able */ ReflectWatch, /* Initialize notifier */ NULL, /* Get OS handle from the channel. NULL'able */ - NULL, /* No close2 support. NULL'able */ + ReflectClose, /* No close2 support. NULL'able */ ReflectBlock, /* Set blocking/nonblocking. NULL'able */ NULL, /* Flush channel. Not used by core. NULL'able */ NULL, /* Handle events. NULL'able */ @@ -81,7 +79,7 @@ static const Tcl_ChannelType tclRChannelType = { #if TCL_THREADS ReflectThread, /* thread action, tracking owner */ #else - NULL, /* thread action */ + (void *)-1, /* thread action */ #endif NULL /* truncate */ }; @@ -493,7 +491,7 @@ static const char *msg_dstlost = "-code 1 -level 0 -errorcode NONE -errorinfo int TclChanCreateObjCmd( - ClientData clientData, + ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -519,6 +517,7 @@ TclChanCreateObjCmd( * this interp. */ Tcl_HashEntry *hPtr; /* Entry in the above map */ int isNew; /* Placeholder. */ + (void)dummy; /* * Syntax: chan create MODE CMDPREFIX @@ -682,7 +681,7 @@ TclChanCreateObjCmd( * as the actual channel type. */ - Tcl_ChannelType *clonePtr = Tcl_Alloc(sizeof(Tcl_ChannelType)); + Tcl_ChannelType *clonePtr = (Tcl_ChannelType *)Tcl_Alloc(sizeof(Tcl_ChannelType)); memcpy(clonePtr, &tclRChannelType, sizeof(Tcl_ChannelType)); @@ -697,7 +696,6 @@ TclChanCreateObjCmd( clonePtr->blockModeProc = NULL; } if (!(methods & FLAG(METH_SEEK))) { - clonePtr->seekProc = NULL; clonePtr->wideSeekProc = NULL; } @@ -782,6 +780,7 @@ ReflectEventRun( */ ReflectEvent *e = (ReflectEvent *) ev; + (void)flags; Tcl_NotifyChannel(e->rcPtr->chan, e->events); return 1; @@ -810,7 +809,7 @@ ReflectEventDelete( int TclChanPostEventObjCmd( - ClientData clientData, + ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) @@ -839,6 +838,7 @@ TclChanPostEventObjCmd( ReflectedChannelMap *rcmPtr;/* Map of reflected channels with handlers in * this interp. */ Tcl_HashEntry *hPtr; /* Entry in the above map */ + (void)dummy; /* * Number of arguments... @@ -883,7 +883,7 @@ TclChanPostEventObjCmd( * have gone seriously haywire. */ - chan = Tcl_GetHashValue(hPtr); + chan = (Tcl_Channel)Tcl_GetHashValue(hPtr); chanTypePtr = Tcl_GetChannelType(chan); /* @@ -899,7 +899,7 @@ TclChanPostEventObjCmd( Tcl_Panic("TclChanPostEventObjCmd: channel is not a reflected channel"); } - rcPtr = Tcl_GetChannelInstanceData(chan); + rcPtr = (ReflectedChannel *)Tcl_GetChannelInstanceData(chan); if (rcPtr->interp != interp) { Tcl_Panic("TclChanPostEventObjCmd: postevent accepted for call from outside interpreter"); @@ -946,7 +946,7 @@ TclChanPostEventObjCmd( } #if TCL_THREADS } else { - ReflectEvent *ev = Tcl_Alloc(sizeof(ReflectEvent)); + ReflectEvent *ev = (ReflectEvent *)Tcl_Alloc(sizeof(ReflectEvent)); ev->header.proc = ReflectEventRun; ev->events = events; @@ -995,7 +995,7 @@ static void TimerRunRead( ClientData clientData) { - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; rcPtr->readTimer = NULL; Tcl_NotifyChannel(rcPtr->chan, TCL_READABLE); } @@ -1004,7 +1004,7 @@ static void TimerRunWrite( ClientData clientData) { - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; rcPtr->writeTimer = NULL; Tcl_NotifyChannel(rcPtr->chan, TCL_WRITABLE); } @@ -1151,9 +1151,10 @@ TclChanCaughtErrorBypass( static int ReflectClose( ClientData clientData, - Tcl_Interp *interp) + Tcl_Interp *interp, + int flags) { - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; int result; /* Result code for 'close' */ Tcl_Obj *resObj; /* Result data for 'close' */ ReflectedChannelMap *rcmPtr;/* Map of reflected channels with handlers in @@ -1161,6 +1162,10 @@ ReflectClose( Tcl_HashEntry *hPtr; /* Entry in the above map */ const Tcl_ChannelType *tctPtr; + if ((flags & (TCL_CLOSE_READ | TCL_CLOSE_WRITE)) != 0) { + return EINVAL; + } + if (TclInThreadExit()) { /* * This call comes from TclFinalizeIOSystem. There are no @@ -1310,7 +1315,7 @@ ReflectInput( int toRead, int *errorCodePtr) { - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; Tcl_Obj *toReadObj; size_t bytec = 0; /* Number of returned bytes */ unsigned char *bytev; /* Array of returned bytes */ @@ -1420,7 +1425,7 @@ ReflectOutput( int toWrite, int *errorCodePtr) { - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; Tcl_Obj *bufObj; Tcl_Obj *resObj; /* Result data for 'write' */ int written; @@ -1549,7 +1554,7 @@ ReflectSeekWide( int seekMode, int *errorCodePtr) { - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; Tcl_Obj *offObj, *baseObj; Tcl_Obj *resObj; /* Result for 'seek' */ Tcl_WideInt newLoc; @@ -1617,24 +1622,6 @@ ReflectSeekWide( newLoc = -1; goto stop; } - -static int -ReflectSeek( - ClientData clientData, - long offset, - int seekMode, - int *errorCodePtr) -{ - /* - * This function can be invoked from a transformation which is based on - * standard seeking, i.e. non-wide. Because of this we have to implement - * it, a dummy is not enough. We simply delegate the call to the wide - * routine. - */ - - return ReflectSeekWide(clientData, offset, seekMode, - errorCodePtr); -} /* *---------------------------------------------------------------------- @@ -1658,7 +1645,7 @@ ReflectWatch( ClientData clientData, int mask) { - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; Tcl_Obj *maskObj; /* @@ -1730,7 +1717,7 @@ ReflectBlock( ClientData clientData, int nonblocking) { - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; Tcl_Obj *blockObj; int errorNum; /* EINVAL or EOK (success). */ Tcl_Obj *resObj; /* Result data for 'blocking' */ @@ -1797,7 +1784,7 @@ ReflectThread( ClientData clientData, int action) { - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; switch (action) { case TCL_CHANNEL_THREAD_INSERT: @@ -1836,7 +1823,7 @@ ReflectSetOption( const char *optionName, /* Name of requested option */ const char *newValue) /* The new value */ { - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; Tcl_Obj *optionObj, *valueObj; int result; /* Result code for 'configure' */ Tcl_Obj *resObj; /* Result data for 'configure' */ @@ -1913,7 +1900,7 @@ ReflectGetOption( * The bypass functions are not required. */ - ReflectedChannel *rcPtr = clientData; + ReflectedChannel *rcPtr = (ReflectedChannel *)clientData; Tcl_Obj *optionObj; Tcl_Obj *resObj; /* Result data for 'configure' */ int listc, result = TCL_OK; @@ -1926,7 +1913,7 @@ ReflectGetOption( #if TCL_THREADS if (rcPtr->thread != Tcl_GetCurrentThread()) { - int opcode; + ForwardedOperation opcode; ForwardParam p; p.getOpt.name = optionName; @@ -2178,9 +2165,9 @@ NewReflectedChannel( Tcl_Obj *handleObj) { ReflectedChannel *rcPtr; - MethodName mn = METH_BLOCKING; + int mn = 0; - rcPtr = Tcl_Alloc(sizeof(ReflectedChannel)); + rcPtr = (ReflectedChannel *)Tcl_Alloc(sizeof(ReflectedChannel)); /* rcPtr->chan: Assigned by caller. Dummy data here. */ @@ -2199,7 +2186,7 @@ NewReflectedChannel( rcPtr->cmd = TclListObjCopy(NULL, cmdpfxObj); Tcl_IncrRefCount(rcPtr->cmd); rcPtr->methods = Tcl_NewListObj(METH_WRITE + 1, NULL); - while (mn <= METH_WRITE) { + while (mn <= (int)METH_WRITE) { Tcl_ListObjAppendElement(NULL, rcPtr->methods, Tcl_NewStringObj(methodNames[mn++], -1)); } @@ -2500,10 +2487,10 @@ static ReflectedChannelMap * GetReflectedChannelMap( Tcl_Interp *interp) { - ReflectedChannelMap *rcmPtr = Tcl_GetAssocData(interp, RCMKEY, NULL); + ReflectedChannelMap *rcmPtr = (ReflectedChannelMap *)Tcl_GetAssocData(interp, RCMKEY, NULL); if (rcmPtr == NULL) { - rcmPtr = Tcl_Alloc(sizeof(ReflectedChannelMap)); + rcmPtr = (ReflectedChannelMap *)Tcl_Alloc(sizeof(ReflectedChannelMap)); Tcl_InitHashTable(&rcmPtr->map, TCL_STRING_KEYS); Tcl_SetAssocData(interp, RCMKEY, (Tcl_InterpDeleteProc *) DeleteReflectedChannelMap, rcmPtr); @@ -2558,7 +2545,7 @@ DeleteReflectedChannelMap( ClientData clientData, /* The per-interpreter data structure. */ Tcl_Interp *interp) /* The interpreter being deleted. */ { - ReflectedChannelMap *rcmPtr = clientData; + ReflectedChannelMap *rcmPtr = (ReflectedChannelMap *)clientData; /* The map */ Tcl_HashSearch hSearch; /* Search variable. */ Tcl_HashEntry *hPtr; /* Search variable. */ @@ -2585,8 +2572,8 @@ DeleteReflectedChannelMap( for (hPtr = Tcl_FirstHashEntry(&rcmPtr->map, &hSearch); hPtr != NULL; hPtr = Tcl_FirstHashEntry(&rcmPtr->map, &hSearch)) { - chan = Tcl_GetHashValue(hPtr); - rcPtr = Tcl_GetChannelInstanceData(chan); + chan = (Tcl_Channel)Tcl_GetHashValue(hPtr); + rcPtr = (ReflectedChannel *)Tcl_GetChannelInstanceData(chan); MarkDead(rcPtr); Tcl_DeleteHashEntry(hPtr); @@ -2663,8 +2650,8 @@ DeleteReflectedChannelMap( for (hPtr = Tcl_FirstHashEntry(&rcmPtr->map, &hSearch); hPtr != NULL; hPtr = Tcl_NextHashEntry(&hSearch)) { - chan = Tcl_GetHashValue(hPtr); - rcPtr = Tcl_GetChannelInstanceData(chan); + chan = (Tcl_Channel)Tcl_GetHashValue(hPtr); + rcPtr = (ReflectedChannel *)Tcl_GetChannelInstanceData(chan); if (rcPtr->interp != interp) { /* @@ -2704,7 +2691,7 @@ GetThreadReflectedChannelMap(void) ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); if (!tsdPtr->rcmPtr) { - tsdPtr->rcmPtr = Tcl_Alloc(sizeof(ReflectedChannelMap)); + tsdPtr->rcmPtr = (ReflectedChannelMap *)Tcl_Alloc(sizeof(ReflectedChannelMap)); Tcl_InitHashTable(&tsdPtr->rcmPtr->map, TCL_STRING_KEYS); Tcl_CreateThreadExitHandler(DeleteThreadReflectedChannelMap, NULL); } @@ -2732,13 +2719,14 @@ GetThreadReflectedChannelMap(void) static void DeleteThreadReflectedChannelMap( - ClientData clientData) /* The per-thread data structure. */ + ClientData dummy) /* The per-thread data structure. */ { Tcl_HashSearch hSearch; /* Search variable. */ Tcl_HashEntry *hPtr; /* Search variable. */ Tcl_ThreadId self = Tcl_GetCurrentThread(); ReflectedChannelMap *rcmPtr; /* The map */ ForwardingResult *resultPtr; + (void)dummy; /* * The origin thread for one or more reflected channels is gone. @@ -2821,8 +2809,8 @@ DeleteThreadReflectedChannelMap( for (hPtr = Tcl_FirstHashEntry(&rcmPtr->map, &hSearch); hPtr != NULL; hPtr = Tcl_FirstHashEntry(&rcmPtr->map, &hSearch)) { - Tcl_Channel chan = Tcl_GetHashValue(hPtr); - ReflectedChannel *rcPtr = Tcl_GetChannelInstanceData(chan); + Tcl_Channel chan = (Tcl_Channel)Tcl_GetHashValue(hPtr); + ReflectedChannel *rcPtr = (ReflectedChannel *)Tcl_GetChannelInstanceData(chan); MarkDead(rcPtr); Tcl_DeleteHashEntry(hPtr); @@ -2867,8 +2855,8 @@ ForwardOpToHandlerThread( * Create and initialize the event and data structures. */ - evPtr = Tcl_Alloc(sizeof(ForwardingEvent)); - resultPtr = Tcl_Alloc(sizeof(ForwardingResult)); + evPtr = (ForwardingEvent *)Tcl_Alloc(sizeof(ForwardingEvent)); + resultPtr = (ForwardingResult *)Tcl_Alloc(sizeof(ForwardingResult)); evPtr->event.proc = ForwardProc; evPtr->resultPtr = resultPtr; @@ -2985,6 +2973,7 @@ ForwardProc( ReflectedChannelMap *rcmPtr;/* Map of reflected channels with handlers in * this interp. */ Tcl_HashEntry *hPtr; /* Entry in the above map */ + (void)mask; /* * Ignore the event if no one is waiting for its result anymore. @@ -3248,7 +3237,7 @@ ForwardProc( * Odd number of elements is wrong. [x]. */ - char *buf = Tcl_Alloc(200); + char *buf = (char *)Tcl_Alloc(200); sprintf(buf, "{Expected list with even number of elements, got %d %s instead}", listc, (listc == 1 ? "element" : "elements")); @@ -3305,7 +3294,7 @@ static void SrcExitProc( ClientData clientData) { - ForwardingEvent *evPtr = clientData; + ForwardingEvent *evPtr = (ForwardingEvent *)clientData; ForwardingResult *resultPtr; ForwardParam *paramPtr; |