OriginalBugID: 4846 Bug
Version: 8.3
SubmitDate: '2000-04-04'
LastModified: '2000-04-25'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 4913
OS: Windows 2000
FixedDate: '2000-04-25'
FixedInVersion: 8.3.1
ClosedDate: '2000-10-25'
Name:
David Gravereaux
CustomShell:
Andreas Kupries' Tcl_ConditionFinalize patch
Comments:
This depends on Andreas Kupries' Tcl_ConditionFinalize patch he
gave me yesterday. Next is making TclpCreateThread public, then
we can build it.
ObservedBehavior:
We can't build the thread extension yet.
1) TclFinalizeCondition and TclpCreateThread aren't exported
2) no makefile.vc
This patch addresses the second and part of the first.
test and install targets are missing from makefile.vc, but this
is a step closer, at least.
Patch:
Index: threadCmd.c
===================================================================
RCS file: /cvsroot/thread/generic/threadCmd.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 threadCmd.c
*** threadCmd.c2000/01/19 22:57:231.1.1.1
--- threadCmd.c2000/04/04 22:15:18
***************
*** 15,21 ****
* RCS: @(#) $Id: threadCmd.c,v 1.1.1.1 2000/01/19 22:57:23 welch Exp $
*/
! #include "tcl.h"
/*
* Each thread has an single instance of the following structure. There
--- 15,22 ----
* RCS: @(#) $Id: threadCmd.c,v 1.1.1.1 2000/01/19 22:57:23 welch Exp $
*/
! #include "thread.h"
! #include <tcl.h>
/*
* Each thread has an single instance of the following structure. There
***************
*** 125,131 ****
EXTERN intThreadObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
EXTERN intThread_Create _ANSI_ARGS_((Tcl_Interp *interp,
! CONST char *script));
EXTERN intThread_List _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN intThread_Send _ANSI_ARGS_((Tcl_Interp *interp, Tcl_ThreadId id,
char *script, int wait));
--- 126,132 ----
EXTERN intThreadObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
EXTERN intThread_Create _ANSI_ARGS_((Tcl_Interp *interp,
! CONST char *script, int stacksize));
EXTERN intThread_List _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN intThread_Send _ANSI_ARGS_((Tcl_Interp *interp, Tcl_ThreadId id,
char *script, int wait));
***************
*** 135,140 ****
--- 136,143 ----
#ifdef MAC_TCL
static pascal void *NewThread _ANSI_ARGS_((ClientData clientData));
+ #elif defined __WIN32__
+ static unsigned __stdcall NewThread _ANSI_ARGS_((ClientData clientData));
#else
static void NewThread _ANSI_ARGS_((ClientData clientData));
#endif
***************
*** 168,179 ****
Thread_Init(interp)
Tcl_Interp *interp; /* The current Tcl interpreter */
{
! if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
return TCL_ERROR;
}
Tcl_CreateObjCommand(interp,"thread", ThreadObjCmd,
(ClientData)NULL ,NULL);
! if (Tcl_PkgProvide(interp, "Thread", "2.0" ) != TCL_OK) {
return TCL_ERROR;
}
return TCL_OK;
--- 171,190 ----
Thread_Init(interp)
Tcl_Interp *interp; /* The current Tcl interpreter */
{
! /* TODO: change this to require 8.4 */
! if (Tcl_InitStubs(interp, "8.3", 0) == NULL) {
return TCL_ERROR;
}
+ if (Tcl_GetVar2(interp, "tcl_platform", "threaded", 0) == NULL) {
+ Tcl_SetResult(interp,
+ "This core wasn't compiled for multithreading. "
+ "You cannot use the thread extension with this core.",
+ TCL_STATIC);
+ return TCL_ERROR;
+ }
Tcl_CreateObjCommand(interp,"thread", ThreadObjCmd,
(ClientData)NULL ,NULL);
! if (Tcl_PkgProvide(interp, "Thread", THREAD_PATCH_LEVEL ) != TCL_OK) {
return TCL_ERROR;
}
return TCL_OK;
***************
*** 252,258 ****
Tcl_WrongNumArgs(interp, 2, objv, "?script?");
return TCL_ERROR;
}
! return ThreadCreate(interp, script);
}
case THREAD_EXIT: {
if (objc > 2) {
--- 263,269 ----
Tcl_WrongNumArgs(interp, 2, objv, "?script?");
return TCL_ERROR;
}
! return Thread_Create(interp, script, 0);
}
case THREAD_EXIT: {
if (objc > 2) {
***************
*** 356,362 ****
/* ARGSUSED */
int
! ThreadCreate(interp, script, stacksize)
Tcl_Interp *interp;/* Current interpreter. */
CONST char *script;/* Script to execute */
int stacksize;/* zero for default size */
--- 367,373 ----
/* ARGSUSED */
int
! Thread_Create(interp, script, stacksize)
Tcl_Interp *interp;/* Current interpreter. */
CONST char *script;/* Script to execute */
int stacksize;/* zero for default size */
***************
*** 382,388 ****
Tcl_ConditionWait(&ctrl.condWait, &threadMutex, NULL);
Tcl_MutexUnlock(&threadMutex);
! TclFinalizeCondition(&ctrl.condWait);
Tcl_SetObjResult(interp, Tcl_NewLongObj((long)id));
return TCL_OK;
}
--- 393,399 ----
Tcl_ConditionWait(&ctrl.condWait, &threadMutex, NULL);
Tcl_MutexUnlock(&threadMutex);
! Tcl_ConditionFinalize(&ctrl.condWait);
Tcl_SetObjResult(interp, Tcl_NewLongObj((long)id));
return TCL_OK;
}
***************
*** 417,422 ****
--- 428,435 ----
*/
#ifdef MAC_TCL
static pascal void *
+ #elif defined __WIN32__
+ static unsigned __stdcall
#else
static void
#endif
***************
*** 478,483 ****
--- 491,498 ----
Tcl_ExitThread(result);
#ifdef MAC_TCL
return NULL;
+ #elif defined __WIN32__
+ return 0;
#endif
}
***************
*** 774,780 ****
}
}
Tcl_SetResult(interp, resultPtr->result, TCL_DYNAMIC);
! TclFinalizeCondition(&resultPtr->done);
code = resultPtr->code;
ckfree((char *) resultPtr);
--- 789,795 ----
}
}
Tcl_SetResult(interp, resultPtr->result, TCL_DYNAMIC);
! Tcl_ConditionFinalize(&resultPtr->done);
code = resultPtr->code;
ckfree((char *) resultPtr);
*** nil.txt Sat Mar 04 12:00:24 2000
--- thread\generic\thread.h Sat Mar 04 14:52:53 2000
***************
*** 0 ****
--- 1,5 ----
+ /* RCS: @(#) $Id:$ */
+
+ #define THREAD_MAJOR_VERSION 2
+ #define THREAD_MINOR_VERSION 0
+ #define THREAD_PATCH_LEVEL "2.0"
*** nil.txt Sat Mar 04 12:00:24 2000
--- thread\win\makefile.vc Sun Mar 05 12:51:09 2000
***************
*** 0 ****
--- 1,132 ----
+ # RCS: @(#) $Id:$
+
+ !include "config.vc"
+
+ !if "$(NODEBUG)" == "0"
+ TMPDIRNAME = Debug
+ DBGX = d
+ !else
+ TMPDIRNAME = Release
+ DBGX =
+ !endif
+
+ SOURCEROOT = ..
+ GENERICDIR = $(SOURCEROOT)\generic
+ WINDIR = $(SOURCEROOT)\win
+ TMPDIR = $(WINDIR)\$(TMPDIRNAME)
+ OUTDIR = $(WINDIR)\$(TMPDIRNAME)
+
+ THREADLIB = $(OUTDIR)\thread$(DBGX).dll
+
+ THREADOBJS = \
+ $(TMPDIR)\threadCmd.obj \
+ $(TMPDIR)\resource.obj
+
+
+ ######################################################################
+ # Compile flags
+ ######################################################################
+
+ !if "$(NODEBUG)" == "0"
+ cdebug = -Z7 -Od -WX
+ !else
+ cdebug = -O2 -Gs -GD
+ !endif
+
+ # I have better luck mixing debug/release builds with Tcl this way...
+ cvarsmt = -MT$(DBGX)
+
+ cflags = -c -W3 -nologo -YX $(cdebug) $(cvarsmt) $(include32) \
+ -Fp$(TMPDIR)\ -Fo$(TMPDIR)\ -I"$(TCLROOT)\generic"
+
+ ######################################################################
+ # Link flags
+ ######################################################################
+
+ !if "$(NODEBUG)" == "0"
+ ldebug = -opt:noref -debug -debugtype:cv
+ !else
+ ldebug = -opt:ref -release
+ !endif
+
+ # declarations common to all linker options
+ lcommon = -nologo -incremental:no -machine:$(MACHINE) $(ldebug)
+
+ conlflags = $(lcommon) -subsystem:console
+ guilflags = $(lcommon) -subsystem:windows
+ dlllflags = $(lcommon) -subsystem:windows -dll
+ reslflags = -noentry -dll
+
+
+ ######################################################################
+ # Project specific targets
+ ######################################################################
+
+ all : $(THREADLIB)
+
+ $(THREADLIB) : $(TMPDIR)\nul $(OUTDIR)\nul $(THREADOBJS)
+ @echo Linking...
+ @$(link32) $(dlllflags) /nodefaultlib:msvcrt -out:$@ $(TCLSTUBSLIB) @<<
+ $(THREADOBJS)
+ <<nokeep
+
+ # Create the output and temp directories, if not already there.
+ # Won't error with a forced rebuild_all (ie. nmake -a ...).
+ #
+ $(TMPDIR)\nul :
+ @if not exist $(TMPDIR)\nul md $(TMPDIR) &\
+ echo Created directory '$(TMPDIR)'
+
+ !if "$(TMPDIR)" != "$(OUTDIR)"
+ $(OUTDIR)\nul :
+ @if not exist $(OUTDIR)\nul md $(OUTDIR) &\
+ echo Created directory '$(OUTDIR)'
+ !endif
+
+ ######################################################################
+ # Inference rules
+ ######################################################################
+
+ # use batch-mode when nmake supports it.
+ #
+ !if $(_NMAKE_VER) < 162
+ {$(GENERICDIR)}.c{$(TMPDIR)}.obj :
+ @echo Compiling...
+ @$(cc32) $(cflags) -DUSE_TCL_STUBS -DTCL_THREADS=1 $<
+ !else
+ {$(GENERICDIR)}.c{$(TMPDIR)}.obj ::
+ @echo Compiling...
+ @$(cc32) $(cflags) -DUSE_TCL_STUBS -DTCL_THREADS=1 @<<
+ $<
+ <<nokeep
+ !endif
+
+
+ ######################################################################
+ # Special case targets
+ ######################################################################
+
+ $(TMPDIR)\thread.res : $(WINDIR)\thread.rc
+ @echo Compiling resources...
+ @$(rc32) -fo"$@" -i "$(GENERICDIR)" -r -DNODEBUG=$(NODEBUG) $(WINDIR)\thread.rc
+
+ $(TMPDIR)\resource.obj : $(TMPDIR)\thread.res
+ @$(cvtres32) -nologo -machine:$(MACHINE) -out:$@ $(TMPDIR)\thread.res
+
+
+ ######################################################################
+ # Dedependency rules
+ ######################################################################
+
+ $(WINDIR)\thread.rc : $(GENERICDIR)\thread.h
+
+ $(GENERICDIR)\threadCmd.c : $(GENERICDIR)\thread.h
+
+
+ ######################################################################
+ # Cleanup
+ ######################################################################
+
+ clean:
+ @if exist $(OUTDIR)\nul rmdir /s /q $(OUTDIR)
+ @if exist $(TMPDIR)\nul rmdir /s /q $(TMPDIR)
*** nil.txt Sat Mar 04 12:00:24 2000
--- thread\win\config.vc Sun Mar 05 21:23:48 2000
***************
*** 0 ****
--- 1,27 ----
+ ######################################################################
+ #
+ # Edit to your paths
+ #
+ # RCS: @(#) $Id:$
+ ######################################################################
+
+ # only affects the linker and resource compiler
+ # pick from:
+ # ALPHA|ARM|IX86|MIPS|MIPS16|MIPSR41XX|PPC|SH3|SH4
+ MACHINE = IX86
+
+ MSDEVROOT = C:\Dev\DevStudio
+ TCLROOT = ..\..\MainTclTrunk
+ TCLSTUBSLIB = "$(TCLROOT)\win\release\tclstub83.lib"
+
+ # Set NODEBUG to 0 to compile with symbols
+ NODEBUG = 1
+
+
+ MSDEVBIN = $(MSDEVROOT)\vc\bin
+ libpath32 = /libpath:"$(MSDEVROOT)\vc\lib"
+ include32 = -I "$(MSDEVROOT)\vc\include"
+
+ cc32 = "$(MSDEVBIN)\cl.exe"
+ rc32 = "$(MSDEVROOT)\sharedide\bin\rc.exe"
+ link32 = "$(MSDEVBIN)\link.exe"
+ cvtres32 = "$(MSDEVBIN)\cvtres.exe"
*** nil.txt Sat Mar 04 12:00:24 2000
--- thread\win\thread.rc Sat Mar 04 13:59:12 2000
***************
*** 0 ****
--- 1,47 ----
+ // RCS: @(#) $Id:$
+ //
+ // Version resource script
+ //
+
+ #define VS_VERSION_INFO 1
+
+ #include <thread.h>
+
+ LANGUAGE 0x9, 0x1 /* LANG_ENGLISH, SUBLANG_DEFAULT */
+
+ VS_VERSION_INFO VERSIONINFO
+ FILEVERSION THREAD_MAJOR_VERSION,THREAD_MINOR_VERSION,0,0
+ PRODUCTVERSION THREAD_MAJOR_VERSION,THREAD_MINOR_VERSION,0,0
+ FILEFLAGSMASK 0x3fL
+ #if NODEBUG == 0
+ FILEFLAGS 0x1L
+ #else
+ FILEFLAGS 0x0L
+ #endif
+ FILEOS 0x4 /* VOS__WINDOWS32 */
+ FILETYPE 0x2 /* VFT_DLL */
+ FILESUBTYPE 0x0L
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0" /* LANG_ENGLISH/SUBLANG_ENGLISH_US, Unicode CP */
+ BEGIN
+ VALUE "FileDescription", "Threading extension library for Tcl\0"
+ #if NODEBUG == 0
+ VALUE "OriginalFilename", "threadd.dll\0"
+ #else
+ VALUE "OriginalFilename", "thread.dll\0"
+ #endif
+ VALUE "CompanyName", "Scriptics Corporation\0"
+ VALUE "FileVersion", THREAD_PATCH_LEVEL
+ VALUE "LegalCopyright", "Copyright (c) 2000 by Scriptics Corporation\0"
+ VALUE "ProductName", "Tcl for Windows\0"
+ VALUE "ProductVersion", THREAD_PATCH_LEVEL
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
+
PatchFiles:
generic/threadCmd.c
generic/thread.h (new)
win/makefile.vc (new)
win/config.vc (new)
win/thread.rc (new)
Adopted for thread extension to coincide with 8.3.1
-- 04/25/2000 hobbs
|