OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tcl8.6.12 / pkgs / thread2.8.7 / generic / tclThreadInt.h
1 /*
2  * --------------------------------------------------------------------------
3  * tclthreadInt.h --
4  *
5  * Global internal header file for the thread extension.
6  *
7  * Copyright (c) 2002 ActiveState Corporation.
8  * Copyright (c) 2002 by Zoran Vasiljevic.
9  *
10  * See the file "license.terms" for information on usage and redistribution
11  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12  * ---------------------------------------------------------------------------
13  */
14
15 #ifndef _TCL_THREAD_INT_H_
16 #define _TCL_THREAD_INT_H_
17
18 #include "tclThread.h"
19 #include <stdlib.h> /* For strtoul */
20 #include <string.h> /* For memset and friends */
21
22 /*
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)
26  */
27 #if defined(_MSC_VER)
28 #   pragma warning(disable:4244)
29 #   if _MSC_VER >= 1400
30 #       pragma warning(disable:4267)
31 #       pragma warning(disable:4996)
32 #   endif
33 #endif
34
35 /*
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).
38  */
39
40 #ifndef MODULE_SCOPE
41 #   ifdef __cplusplus
42 #       define MODULE_SCOPE extern "C"
43 #   else
44 #       define MODULE_SCOPE extern
45 #   endif
46 #endif
47
48 /*
49  * For linking against NaviServer/AOLserver require V4 at least
50  */
51
52 #ifdef NS_AOLSERVER
53 # include <ns.h>
54 # if !defined(NS_MAJOR_VERSION) || NS_MAJOR_VERSION < 4
55 #  error "unsupported NaviServer/AOLserver version"
56 # endif
57 #endif
58
59 /*
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.
64  */
65
66 #define THREAD_CMD_PREFIX "thread::"
67 #define TPOOL_CMD_PREFIX  "tpool::"
68
69 /*
70  * Exported from threadSvCmd.c file.
71  */
72
73 MODULE_SCOPE const char *SvInit(Tcl_Interp *interp);
74
75 /*
76  * Exported from threadSpCmd.c file.
77  */
78
79 MODULE_SCOPE const char *SpInit(Tcl_Interp *interp);
80
81 /*
82  * Exported from threadPoolCmd.c file.
83  */
84
85 MODULE_SCOPE const char *TpoolInit(Tcl_Interp *interp);
86
87 /*
88  * Macros for splicing in/out of linked lists
89  */
90
91 #define SpliceIn(a,b)                          \
92     (a)->nextPtr = (b);                        \
93     if ((b) != NULL)                           \
94         (b)->prevPtr = (a);                    \
95     (a)->prevPtr = NULL, (b) = (a)
96
97 #define SpliceOut(a,b)                         \
98     if ((a)->prevPtr != NULL)                  \
99         (a)->prevPtr->nextPtr = (a)->nextPtr;  \
100     else                                       \
101         (b) = (a)->nextPtr;                    \
102     if ((a)->nextPtr != NULL)                  \
103         (a)->nextPtr->prevPtr = (a)->prevPtr
104
105 /*
106  * Version macros
107  */
108
109 #define TCL_MINIMUM_VERSION(major,minor) \
110   ((TCL_MAJOR_VERSION > (major)) || \
111     ((TCL_MAJOR_VERSION == (major)) && (TCL_MINOR_VERSION >= (minor))))
112
113 /*
114  * Utility macros
115  */
116
117 #define TCL_CMD(a,b,c) \
118   if (Tcl_CreateObjCommand((a),(b),(c),NULL, NULL) == NULL) \
119     return NULL;
120
121 #define OPT_CMP(a,b) \
122   ((a) && (b) && ((a)[0]==(b)[0]) && ((a)[1]==(b)[1]) && (!strcmp((a),(b))))
123
124 #ifndef TCL_TSD_INIT
125 #define TCL_TSD_INIT(keyPtr) \
126   (ThreadSpecificData*)Tcl_GetThreadData((keyPtr),sizeof(ThreadSpecificData))
127 #endif
128
129 /*
130  * Structure to pass to NsThread_Init. This holds the module
131  * and virtual server name for proper interp initializations.
132  */
133
134 typedef struct {
135     char *modname;
136     char *server;
137 } NsThreadInterpData;
138
139 /*
140  * Handle binary compatibility regarding
141  * Tcl_GetErrorLine in 8.x
142  * See Tcl bug #3562640.
143  */
144
145 MODULE_SCOPE int threadTclVersion;
146
147 typedef struct {
148     void *unused1;
149     void *unused2;
150     int errorLine;
151 } tclInterpType;
152
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))
158 /* TIP #270 */
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))
163 /* TIP #337 */
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)
171 #endif
172
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".
178  */
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))
191 #endif
192
193 #endif /* _TCL_THREAD_INT_H_ */