2 * --------------------------------------------------------------------------
5 * Global internal header file for the thread extension.
7 * Copyright (c) 2002 ActiveState Corporation.
8 * Copyright (c) 2002 by Zoran Vasiljevic.
10 * See the file "license.terms" for information on usage and redistribution
11 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12 * ---------------------------------------------------------------------------
15 #ifndef _TCL_THREAD_INT_H_
16 #define _TCL_THREAD_INT_H_
18 #include "tclThread.h"
19 #include <stdlib.h> /* For strtoul */
20 #include <string.h> /* For memset and friends */
23 * MSVC 8.0 started to mark many standard C library functions depreciated
24 * including the *printf family and others. Tell it to shut up.
25 * (_MSC_VER is 1200 for VC6, 1300 or 1310 for vc7.net, 1400 for 8.0)
28 # pragma warning(disable:4244)
30 # pragma warning(disable:4267)
31 # pragma warning(disable:4996)
36 * Used to tag functions that are only to be visible within the module being
37 * built and not outside it (where this is supported by the linker).
42 # define MODULE_SCOPE extern "C"
44 # define MODULE_SCOPE extern
49 * For linking against NaviServer/AOLserver require V4 at least
54 # if !defined(NS_MAJOR_VERSION) || NS_MAJOR_VERSION < 4
55 # error "unsupported NaviServer/AOLserver version"
60 * Allow for some command names customization.
61 * Only thread:: and tpool:: are handled here.
62 * Shared variable commands are more complicated.
63 * Look into the threadSvCmd.h for more info.
66 #define THREAD_CMD_PREFIX "thread::"
67 #define TPOOL_CMD_PREFIX "tpool::"
70 * Exported from threadSvCmd.c file.
73 MODULE_SCOPE const char *SvInit(Tcl_Interp *interp);
76 * Exported from threadSpCmd.c file.
79 MODULE_SCOPE const char *SpInit(Tcl_Interp *interp);
82 * Exported from threadPoolCmd.c file.
85 MODULE_SCOPE const char *TpoolInit(Tcl_Interp *interp);
88 * Macros for splicing in/out of linked lists
91 #define SpliceIn(a,b) \
95 (a)->prevPtr = NULL, (b) = (a)
97 #define SpliceOut(a,b) \
98 if ((a)->prevPtr != NULL) \
99 (a)->prevPtr->nextPtr = (a)->nextPtr; \
101 (b) = (a)->nextPtr; \
102 if ((a)->nextPtr != NULL) \
103 (a)->nextPtr->prevPtr = (a)->prevPtr
109 #define TCL_MINIMUM_VERSION(major,minor) \
110 ((TCL_MAJOR_VERSION > (major)) || \
111 ((TCL_MAJOR_VERSION == (major)) && (TCL_MINOR_VERSION >= (minor))))
117 #define TCL_CMD(a,b,c) \
118 if (Tcl_CreateObjCommand((a),(b),(c),NULL, NULL) == NULL) \
121 #define OPT_CMP(a,b) \
122 ((a) && (b) && ((a)[0]==(b)[0]) && ((a)[1]==(b)[1]) && (!strcmp((a),(b))))
125 #define TCL_TSD_INIT(keyPtr) \
126 (ThreadSpecificData*)Tcl_GetThreadData((keyPtr),sizeof(ThreadSpecificData))
130 * Structure to pass to NsThread_Init. This holds the module
131 * and virtual server name for proper interp initializations.
137 } NsThreadInterpData;
140 * Handle binary compatibility regarding
141 * Tcl_GetErrorLine in 8.x
142 * See Tcl bug #3562640.
145 MODULE_SCOPE int threadTclVersion;
153 #if defined(TCL_TIP285) && defined(USE_TCL_STUBS)
154 # undef Tcl_GetErrorLine
155 # define Tcl_GetErrorLine(interp) ((threadTclVersion>85)? \
156 ((int (*)(Tcl_Interp *))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[605]))(interp): \
157 (((tclInterpType *)(interp))->errorLine))
159 # undef Tcl_AddErrorInfo
160 # define Tcl_AddErrorInfo(interp, msg) ((threadTclVersion>85)? \
161 ((void (*)(Tcl_Interp *, Tcl_Obj *))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[574]))(interp, Tcl_NewStringObj(msg, -1)): \
162 ((void (*)(Tcl_Interp *, const char *))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[66]))(interp, msg))
164 # undef Tcl_BackgroundException
165 # define Tcl_BackgroundException(interp, result) ((threadTclVersion>85)? \
166 ((void (*)(Tcl_Interp *, int))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[609]))(interp, result): \
167 ((void (*)(Tcl_Interp *))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[76]))(interp))
168 #elif !TCL_MINIMUM_VERSION(8,6)
169 /* 8.5, 8.4, or less - Emulate access to the error-line information */
170 # define Tcl_GetErrorLine(interp) (((tclInterpType *)(interp))->errorLine)
173 /* When running on Tcl >= 8.7, make sure that Thread still runs when Tcl is compiled
174 * with -DTCL_NO_DEPRECATED=1. Stub entries for Tcl_SetIntObj/Tcl_NewIntObj are NULL then.
175 * Just use Tcl_SetWideIntObj/Tcl_NewWideIntObj in stead. We don't simply want to use
176 * Tcl_SetWideIntObj/Tcl_NewWideIntObj always, since extensions might not expect to
177 * get an actual "wideInt".
179 #if defined(USE_TCL_STUBS)
180 # undef Tcl_SetIntObj
181 # define Tcl_SetIntObj(objPtr, value) ((threadTclVersion>86)? \
182 ((void (*)(Tcl_Obj *, Tcl_WideInt))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[489]))(objPtr, (int)(value)): \
183 ((void (*)(Tcl_Obj *, int))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[61]))(objPtr, value))
184 # undef Tcl_NewIntObj
185 # define Tcl_NewIntObj(value) ((threadTclVersion>86)? \
186 ((Tcl_Obj * (*)(Tcl_WideInt))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[488]))((int)(value)): \
187 ((Tcl_Obj * (*)(int))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[52]))(value))
188 # undef Tcl_GetUnicodeFromObj
189 # define Tcl_GetUnicodeFromObj ((((&(tclStubsPtr->tcl_PkgProvideEx))[378]) != ((&(tclStubsPtr->tcl_PkgProvideEx))[434])) ? \
190 ((void (*)(Tcl_Obj *, int *))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[434])) : ((void (*)(Tcl_Obj *, int *)) NULL))
193 #endif /* _TCL_THREAD_INT_H_ */