From 88d769137e19818849c896edc1fad629212e1734 Mon Sep 17 00:00:00 2001 From: welch Date: Mon, 17 Apr 2000 20:32:21 +0000 Subject: Added Tcl_CreateThreadType and TCL_RETURN_THREAD_TYPE macros for declaring the NewThread callback proc. --- generic/tcl.h | 23 ++++++++++++++++++++++- generic/tclThreadTest.c | 19 +++++-------------- win/tclWinThrd.c | 6 +++--- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index 42b488e..3e49b10 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tcl.h,v 1.68 2000/04/13 02:30:43 hobbs Exp $ + * RCS: @(#) $Id: tcl.h,v 1.69 2000/04/17 20:32:21 welch Exp $ */ #ifndef _TCL @@ -395,10 +395,31 @@ typedef struct Tcl_Var_ *Tcl_Var; #ifdef MAC_TCL typedef pascal void *(Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); +#elif defined __WIN32__ +typedef unsigned (__stdcall Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); #else typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData)); #endif + +/* + * Threading function return types used for abstracting away platform + * differences when writing a Tcl_ThreadCreateProc. See the NewThread + * function in generic/tclThreadTest.c for it's usage. + */ +#ifdef MAC_TCL +# define Tcl_ThreadCreateType pascal void * +# define TCL_THREAD_CREATE_RETURN return NULL +#elif defined __WIN32__ +# define Tcl_ThreadCreateType unsigned __stdcall +# define TCL_THREAD_CREATE_RETURN return 0 +#else +# define Tcl_ThreadCreateType void +# define TCL_THREAD_CREATE_RETURN +#endif + + + /* * Definition of values for default stacksize and the possible flags to be * given to Tcl_CreateThread. diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c index d548423..2ef43bc 100644 --- a/generic/tclThreadTest.c +++ b/generic/tclThreadTest.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclThreadTest.c,v 1.8 2000/04/09 16:04:19 kupries Exp $ + * RCS: @(#) $Id: tclThreadTest.c,v 1.9 2000/04/17 20:32:22 welch Exp $ */ #include "tclInt.h" @@ -126,11 +126,7 @@ EXTERN int TclThreadSend _ANSI_ARGS_((Tcl_Interp *interp, Tcl_ThreadId id, #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT -#ifdef MAC_TCL -static pascal void *NewThread _ANSI_ARGS_((ClientData clientData)); -#else -static void NewThread _ANSI_ARGS_((ClientData clientData)); -#endif +Tcl_ThreadCreateType NewThread _ANSI_ARGS_((ClientData clientData)); static void ListRemove _ANSI_ARGS_((ThreadSpecificData *tsdPtr)); static void ListUpdateInner _ANSI_ARGS_((ThreadSpecificData *tsdPtr)); static int ThreadEventProc _ANSI_ARGS_((Tcl_Event *evPtr, int mask)); @@ -406,11 +402,7 @@ TclCreateThread(interp, script) * *------------------------------------------------------------------------ */ -#ifdef MAC_TCL -static pascal void * -#else -static void -#endif +Tcl_ThreadCreateType NewThread(clientData) ClientData clientData; { @@ -467,9 +459,8 @@ NewThread(clientData) Tcl_Release((ClientData) tsdPtr->interp); Tcl_DeleteInterp(tsdPtr->interp); Tcl_ExitThread(result); -#ifdef MAC_TCL - return NULL; -#endif + + TCL_THREAD_CREATE_RETURN; } /* diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index 5f430b2..e3227b1 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.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. * - * SCCS: @(#) tclWinThrd.c 1.13 98/02/18 14:00:23 + * RCS: @(#) $Id: tclWinThrd.c,v 1.7 2000/04/17 20:32:26 welch Exp $ */ #include "tclWinInt.h" @@ -125,8 +125,8 @@ Tcl_CreateThread(idPtr, proc, clientData, stackSize, flags) { unsigned long code; - code = _beginthreadex(NULL, stackSize, (LPTHREAD_START_ROUTINE) proc, - (void *)clientData, 0, (unsigned *)idPtr); + code = _beginthreadex(NULL, stackSize, proc, clientData, 0, + (unsigned *)idPtr); if (code == 0) { return TCL_ERROR; } else { -- cgit v0.12