From 77806ded9e45e9569f778847e63516f884788da2 Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Thu, 13 Sep 2012 18:30:41 +0000 Subject: Initial work on SF FRQ #3567063. --- win/tclWinThrd.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index 13fd411..7abcc29 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -13,6 +13,7 @@ #include "tclWinInt.h" #include +#include #include #include @@ -122,6 +123,52 @@ typedef struct WinCondition { struct ThreadSpecificData *lastPtr; } WinCondition; +/* + * The per thread data passed from TclpThreadCreate + * to TclWinThreadStart. + */ + +typedef struct WinThread { + LPTHREAD_START_ROUTINE lpStartAddress; /* Original startup routine */ + LPVOID lpParameter; /* Original startup data */ + unsigned int fpControl; /* Floating point control word from the + * main thread */ +} WinThread; + + +/* + *---------------------------------------------------------------------- + * + * TclWinThreadStart -- + * + * This procedure is the entry point for all new threads created + * by Tcl on Windows. + * + * Results: + * Various, depending on the result of the wrapped thread start + * routine. + * + * Side effects: + * Arbitrary, since user code is executed. + * + *---------------------------------------------------------------------- + */ + +static DWORD WINAPI +TclWinThreadStart( + LPVOID lpParameter) /* The WinThread structure pointer passed + * from TclpThreadCreate */ +{ + WinThread *winThreadPtr = (WinThread *) lpParameter; + unsigned int fpmask = _MCW_EM | _MCW_RC | _MCW_PC | _MCW_DN; + + if (!winThreadPtr) { + return TCL_ERROR; + } + + _controlfp(winThreadPtr->fpControl, fpmask); + return winThreadPtr->lpStartAddress(winThreadPtr->lpParameter); +} /* *---------------------------------------------------------------------- @@ -149,17 +196,22 @@ TclpThreadCreate(idPtr, proc, clientData, stackSize, flags) int flags; /* Flags controlling behaviour of * the new thread */ { + WinThread *winThreadPtr; /* Per-thread startup info */ HANDLE tHandle; + winThreadPtr = (WinThread *)ckalloc(sizeof(WinThread)); + winThreadPtr->lpStartAddress = proc; + winThreadPtr->lpParameter = clientData; + winThreadPtr->fpControl = _controlfp(0, 0); + EnterCriticalSection(&joinLock); #if defined(_MSC_VER) || defined(__MSVCRT__) || defined(__BORLANDC__) - tHandle = (HANDLE) _beginthreadex(NULL, (unsigned) stackSize, proc, - clientData, 0, (unsigned *)idPtr); + tHandle = (HANDLE) _beginthreadex(NULL, (unsigned) stackSize, + TclWinThreadStart, winThreadPtr, 0, (unsigned *)idPtr); #else tHandle = CreateThread(NULL, (DWORD) stackSize, - (LPTHREAD_START_ROUTINE) proc, (LPVOID) clientData, - (DWORD) 0, (LPDWORD)idPtr); + TclWinThreadStart, winThreadPtr, 0, (LPDWORD)idPtr); #endif if (tHandle == NULL) { -- cgit v0.12 From c02b64e20cd435142d5924015fadc8dbcd19aa43 Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Thu, 13 Sep 2012 18:37:55 +0000 Subject: Free the WinThread structure before running the original thread procedure. --- win/tclWinThrd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index 7abcc29..86ff6a5 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -161,13 +161,20 @@ TclWinThreadStart( { WinThread *winThreadPtr = (WinThread *) lpParameter; unsigned int fpmask = _MCW_EM | _MCW_RC | _MCW_PC | _MCW_DN; + LPTHREAD_START_ROUTINE lpOrigStartAddress; + LPVOID lpOrigParameter; if (!winThreadPtr) { return TCL_ERROR; } _controlfp(winThreadPtr->fpControl, fpmask); - return winThreadPtr->lpStartAddress(winThreadPtr->lpParameter); + + lpOrigStartAddress = winThreadPtr->lpStartAddress; + lpOrigParameter = winThreadPtr->lpParameter; + + ckfree((char *)winThreadPtr); + return lpOrigStartAddress(lpOrigParameter); } /* -- cgit v0.12 From 9d29fc1ebfbb48cc19bf87541750abfbaeab3c31 Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Thu, 13 Sep 2012 20:03:01 +0000 Subject: Make compilation of the fp control changes possible with MinGW. --- win/tclWinThrd.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index 86ff6a5..21d422f 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -160,7 +160,7 @@ TclWinThreadStart( * from TclpThreadCreate */ { WinThread *winThreadPtr = (WinThread *) lpParameter; - unsigned int fpmask = _MCW_EM | _MCW_RC | _MCW_PC | _MCW_DN; + unsigned int fpmask; LPTHREAD_START_ROUTINE lpOrigStartAddress; LPVOID lpOrigParameter; @@ -168,6 +168,12 @@ TclWinThreadStart( return TCL_ERROR; } + fpmask = _MCW_EM | _MCW_RC | _MCW_PC; + +#if defined(_MSC_VER) && _MSC_VER >= 1200 + fpmask |= _MCW_DN; +#endif + _controlfp(winThreadPtr->fpControl, fpmask); lpOrigStartAddress = winThreadPtr->lpStartAddress; @@ -207,7 +213,7 @@ TclpThreadCreate(idPtr, proc, clientData, stackSize, flags) HANDLE tHandle; winThreadPtr = (WinThread *)ckalloc(sizeof(WinThread)); - winThreadPtr->lpStartAddress = proc; + winThreadPtr->lpStartAddress = (LPTHREAD_START_ROUTINE) proc; winThreadPtr->lpParameter = clientData; winThreadPtr->fpControl = _controlfp(0, 0); @@ -215,7 +221,8 @@ TclpThreadCreate(idPtr, proc, clientData, stackSize, flags) #if defined(_MSC_VER) || defined(__MSVCRT__) || defined(__BORLANDC__) tHandle = (HANDLE) _beginthreadex(NULL, (unsigned) stackSize, - TclWinThreadStart, winThreadPtr, 0, (unsigned *)idPtr); + (Tcl_ThreadCreateProc*) TclWinThreadStart, winThreadPtr, + 0, (unsigned *)idPtr); #else tHandle = CreateThread(NULL, (DWORD) stackSize, TclWinThreadStart, winThreadPtr, 0, (LPDWORD)idPtr); -- cgit v0.12 From de5687769c8034c6d0d32e207f9934e3a3fed533 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 3 Oct 2012 15:18:32 +0000 Subject: When checking for std channels being closed, compare the channel state, not the channel itself so that stacked channels do not cause trouble. --- ChangeLog | 6 ++++++ generic/tclIO.c | 44 ++++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8b9f2b..6f84707 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-10-03 Don Porter + + * generic/tclIO.c: When checking for std channels being closed, + compare the channel state, not the channel itself so that stacked + channels do not cause trouble. + 2012-08-17 Jan Nijtmans * win/nmakehlp.c: Add "-V" option, in order to be able diff --git a/generic/tclIO.c b/generic/tclIO.c index b9cd30c..eace472 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -697,26 +697,30 @@ CheckForStdChannelsBeingClosed(chan) ChannelState *statePtr = ((Channel *) chan)->state; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); - if ((chan == tsdPtr->stdinChannel) && (tsdPtr->stdinInitialized)) { - if (statePtr->refCount < 2) { - statePtr->refCount = 0; - tsdPtr->stdinChannel = NULL; - return; - } - } else if ((chan == tsdPtr->stdoutChannel) - && (tsdPtr->stdoutInitialized)) { - if (statePtr->refCount < 2) { - statePtr->refCount = 0; - tsdPtr->stdoutChannel = NULL; - return; - } - } else if ((chan == tsdPtr->stderrChannel) - && (tsdPtr->stderrInitialized)) { - if (statePtr->refCount < 2) { - statePtr->refCount = 0; - tsdPtr->stderrChannel = NULL; - return; - } + if (tsdPtr->stdinInitialized + && tsdPtr->stdinChannel != NULL + && statePtr == ((Channel *)tsdPtr->stdinChannel)->state) { + if (statePtr->refCount < 2) { + statePtr->refCount = 0; + tsdPtr->stdinChannel = NULL; + return; + } + } else if (tsdPtr->stdoutInitialized + && tsdPtr->stdoutChannel != NULL + && statePtr == ((Channel *)tsdPtr->stdoutChannel)->state) { + if (statePtr->refCount < 2) { + statePtr->refCount = 0; + tsdPtr->stdoutChannel = NULL; + return; + } + } else if (tsdPtr->stderrInitialized + && tsdPtr->stderrChannel != NULL + && statePtr == ((Channel *)tsdPtr->stderrChannel)->state) { + if (statePtr->refCount < 2) { + statePtr->refCount = 0; + tsdPtr->stderrChannel = NULL; + return; + } } } -- cgit v0.12 From b7ab9a658afe9ad4c7fd964c597075c7ea4707e7 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 8 Nov 2012 16:22:35 +0000 Subject: dup test name --- tests/dict.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dict.test b/tests/dict.test index 22d652b..72a336c 100644 --- a/tests/dict.test +++ b/tests/dict.test @@ -1805,7 +1805,7 @@ test dict-24.20 {dict map stack space compilation: 'dict for' bug 1903325} { proc linenumber {} { dict get [info frame -1] line } -test dict-24.20 {dict compilation crash: 'dict for' bug 3487626} { +test dict-24.20.1 {dict compilation crash: 'dict for' bug 3487626} { apply {{} {apply {n { set e {} set k {} -- cgit v0.12 From d677e8a8ae7188b1aebd47c054633273808d5764 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 9 Nov 2012 12:11:04 +0000 Subject: Flag USE_TCLOO_STUBS is not necessary any more for extensions: Stubs are the only way to access TclOO, so it is implied. --- unix/tclooConfig.sh | 2 +- win/tclooConfig.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/tclooConfig.sh b/unix/tclooConfig.sh index dce540a..5cb4d99 100644 --- a/unix/tclooConfig.sh +++ b/unix/tclooConfig.sh @@ -15,5 +15,5 @@ TCLOO_LIB_SPEC="" TCLOO_STUB_LIB_SPEC="" TCLOO_INCLUDE_SPEC="" TCLOO_PRIVATE_INCLUDE_SPEC="" -TCLOO_CFLAGS=-DUSE_TCLOO_STUBS +TCLOO_CFLAGS="" TCLOO_VERSION=0.7 diff --git a/win/tclooConfig.sh b/win/tclooConfig.sh index dce540a..5cb4d99 100644 --- a/win/tclooConfig.sh +++ b/win/tclooConfig.sh @@ -15,5 +15,5 @@ TCLOO_LIB_SPEC="" TCLOO_STUB_LIB_SPEC="" TCLOO_INCLUDE_SPEC="" TCLOO_PRIVATE_INCLUDE_SPEC="" -TCLOO_CFLAGS=-DUSE_TCLOO_STUBS +TCLOO_CFLAGS="" TCLOO_VERSION=0.7 -- cgit v0.12 From 9b833e95c6079739abfbbe5ef2ca028cc651d2b6 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 9 Nov 2012 15:12:01 +0000 Subject: ChangeLog release mark --- ChangeLog | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index d415c56..fb97890 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2012-11-09 Don Porter + + *** 8.5.13 TAGGED FOR RELEASE *** + + * generic/tcl.h: Bump to 8.5.13 for release. + * library/init.tcl: + * tools/tcl.wse.in: + * unix/configure.in: + * unix/tcl.spec: + * win/configure.in: + * README: + + * unix/configure: autoconf-2.59 + * win/configure: + 2012-11-07 Kevin B. Kenny * library/tzdata/Africa/Casablanca: -- cgit v0.12 From 16057dd18ea93316b53bdd6dd940970d1d624687 Mon Sep 17 00:00:00 2001 From: mig Date: Sat, 10 Nov 2012 17:08:33 +0000 Subject: re-enable bcc-tailcall, after fixing an infinite loop in the TCL_COMPILE_DEBUG mode --- generic/tclBasic.c | 2 +- generic/tclExecute.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index cbdbe87..bce6479 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -247,7 +247,7 @@ static const CmdInfo builtInCmds[] = { {"split", Tcl_SplitObjCmd, NULL, NULL, 1}, {"subst", Tcl_SubstObjCmd, TclCompileSubstCmd, TclNRSubstObjCmd, 1}, {"switch", Tcl_SwitchObjCmd, TclCompileSwitchCmd, TclNRSwitchObjCmd, 1}, - {"tailcall", NULL, NULL, TclNRTailcallObjCmd, 1}, + {"tailcall", NULL, TclCompileTailcallCmd, TclNRTailcallObjCmd, 1}, {"throw", Tcl_ThrowObjCmd, TclCompileThrowCmd, NULL, 1}, {"trace", Tcl_TraceObjCmd, NULL, NULL, 1}, {"try", Tcl_TryObjCmd, TclCompileTryCmd, TclNRTryObjCmd, 1}, diff --git a/generic/tclExecute.c b/generic/tclExecute.c index caf35ba..cf8f9e7 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -2393,7 +2393,7 @@ TEBCresume( register int i; TRACE(("%d [", opnd)); - for (i=opnd-1 ; i>=0 ; i++) { + for (i=opnd-1 ; i>=0 ; i--) { TRACE_APPEND(("\"%.30s\"", O2S(OBJ_AT_DEPTH(i)))); if (i > 0) { TRACE_APPEND((" ")); -- cgit v0.12 From 3f954bc0d329901dedd9d5e2327bf1b616b3ed5f Mon Sep 17 00:00:00 2001 From: mig Date: Sat, 10 Nov 2012 19:24:23 +0000 Subject: added forgotten Changelog entry --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3e495cd..ad0bad1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-11-10 Miguel Sofer + + * generic/tclBasic.c: re-enable bcc-tailcall, after fixing an + * generic/tclExecute.c: infinite loop in the TCL_COMPILE_DEBUG mode + + 2012-11-07 Kevin B. Kenny * library/tzdata/Africa/Casablanca: -- cgit v0.12 From d9d6ec203d956036ba912a1fdf6fbba4ae449871 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 12 Nov 2012 07:53:34 +0000 Subject: style fix --- unix/tclLoadNext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/tclLoadNext.c b/unix/tclLoadNext.c index f5911f8..eb0affa 100644 --- a/unix/tclLoadNext.c +++ b/unix/tclLoadNext.c @@ -134,8 +134,8 @@ FindSymbol( const char *symbol) { Tcl_PackageInitProc *proc = NULL; - - if (symbol) { + + if (symbol) { char sym[strlen(symbol) + 2]; sym[0] = '_'; -- cgit v0.12 From a4d552f93c2ab129b82405cb45b7e2324a67cbd7 Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Tue, 13 Nov 2012 19:59:14 +0000 Subject: also search for the library directory (init.tcl, encodings, etc) relative to the build directory associated with the source checkout. --- ChangeLog | 6 ++++++ win/tclWinInit.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fb97890..ee34c44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-11-13 Joe Mistachkin + + * win/tclWinInit.c: also search for the library directory (init.tcl, + encodings, etc) relative to the build directory associated with the + source checkout. + 2012-11-09 Don Porter *** 8.5.13 TAGGED FOR RELEASE *** diff --git a/win/tclWinInit.c b/win/tclWinInit.c index d80fa28..5baf020 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -101,6 +101,10 @@ static TclInitProcessGlobalValueProc InitializeDefaultLibraryDir; static ProcessGlobalValue defaultLibraryDir = {0, 0, NULL, NULL, InitializeDefaultLibraryDir, NULL, NULL}; +static TclInitProcessGlobalValueProc InitializeSourceLibraryDir; +static ProcessGlobalValue sourceLibraryDir = + {0, 0, NULL, NULL, InitializeSourceLibraryDir, NULL, NULL}; + static void AppendEnvironment(Tcl_Obj *listPtr, CONST char *lib); static int ToUtf(CONST WCHAR *wSrc, char *dst); @@ -175,7 +179,7 @@ TclpInitLibraryPath( int *lengthPtr, Tcl_Encoding *encodingPtr) { -#define LIBRARY_SIZE 32 +#define LIBRARY_SIZE 64 Tcl_Obj *pathPtr; char installLib[LIBRARY_SIZE]; char *bytes; @@ -206,6 +210,13 @@ TclpInitLibraryPath( Tcl_ListObjAppendElement(NULL, pathPtr, TclGetProcessGlobalValue(&defaultLibraryDir)); + /* + * Look for the library in its source checkout location. + */ + + Tcl_ListObjAppendElement(NULL, pathPtr, + TclGetProcessGlobalValue(&sourceLibraryDir)); + *encodingPtr = NULL; bytes = Tcl_GetStringFromObj(pathPtr, lengthPtr); *valuePtr = ckalloc((unsigned int)(*lengthPtr)+1); @@ -355,6 +366,57 @@ InitializeDefaultLibraryDir( TclWinNoBackslash(name); sprintf(end + 1, "lib/tcl%s", TCL_VERSION); *lengthPtr = strlen(name); + *valuePtr = ckalloc(*lengthPtr + 1); + *encodingPtr = NULL; + memcpy(*valuePtr, name, (size_t) *lengthPtr + 1); +} + +/* + *--------------------------------------------------------------------------- + * + * InitializeSourceLibraryDir -- + * + * Locate the Tcl script library default location relative to the + * location of the Tcl DLL as it exists in the build output directory + * associated with the source checkout. + * + * Results: + * None. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +static void +InitializeSourceLibraryDir( + char **valuePtr, + int *lengthPtr, + Tcl_Encoding *encodingPtr) +{ + HMODULE hModule = TclWinGetTclInstance(); + WCHAR wName[MAX_PATH + LIBRARY_SIZE]; + char name[(MAX_PATH + LIBRARY_SIZE) * TCL_UTF_MAX]; + char *end, *p; + + if (GetModuleFileNameW(hModule, wName, MAX_PATH) == 0) { + GetModuleFileNameA(hModule, name, MAX_PATH); + } else { + ToUtf(wName, name); + } + + end = strrchr(name, '\\'); + *end = '\0'; + p = strrchr(name, '\\'); + if (p != NULL) { + end = p; + } + *end = '\\'; + + TclWinNoBackslash(name); + sprintf(end + 1, "../library"); + *lengthPtr = strlen(name); *valuePtr = ckalloc((unsigned int) *lengthPtr + 1); *encodingPtr = NULL; memcpy(*valuePtr, name, (size_t) *lengthPtr + 1); -- cgit v0.12