1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
/*
* --------------------------------------------------------------------------
* tclthread.h --
*
* Global header file for the thread extension.
*
* Copyright (c) 2002 ActiveState Corporation.
* Copyright (c) 2002 by Zoran Vasiljevic.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclThread.h,v 1.15 2003/03/17 09:01:23 vasiljevic Exp $
* ---------------------------------------------------------------------------
*/
/*
* Thread extension version numbers are not stored here
* because this isn't a public export file.
*/
#ifndef _TCL_THREAD_H_
#define _TCL_THREAD_H_
#include <tcl.h>
#include <stdlib.h> /* For strtoul */
#include <string.h> /* For memset and friends */
/*
* Starting from 8.4 core, Tcl API is CONST'ified.
* Versions < 8 we do not support anyway.
*/
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION <= 3)
# define CONST84
#endif
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
/*
* Allow for some command names customization.
* Only thread:: and tpool:: are handled here.
* The shared variable is more complicated.
* Look into the threadSvCmd.h for more info.
* The reason for this is that eralier versions
* of AOLserver do not handle namespaced Tcl
* commands properly.
*/
#ifdef NS_AOLSERVER
# include <ns.h>
# define THNS "thread_"
# define TPNS "tpool_"
#else
# define THNS "thread::"
# define TPNS "tpool::"
#endif
/*
* Exported from threadCmd.c file.
*/
EXTERN int Thread_Init _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int Thread_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
/*
* Exported from threadSvCmd.c file.
*/
EXTERN int Sv_Init _ANSI_ARGS_((Tcl_Interp *interp));
/*
* Exported from threadSpCmd.c file.
*/
EXTERN int Sp_Init _ANSI_ARGS_((Tcl_Interp *interp));
/*
* Exported from threadPoolCmd.c file.
*/
EXTERN int Tpool_Init _ANSI_ARGS_((Tcl_Interp *interp));
/*
* Macros for splicing in/out of linked lists
*/
#define SpliceIn(a,b) \
(a)->nextPtr = (b); \
if ((b) != NULL) \
(b)->prevPtr = (a); \
(a)->prevPtr = NULL, (b) = (a);
#define SpliceOut(a,b) \
if ((a)->prevPtr != NULL) \
(a)->prevPtr->nextPtr = (a)->nextPtr; \
else \
(b) = (a)->nextPtr; \
if ((a)->nextPtr != NULL) \
(a)->nextPtr->prevPtr = (a)->prevPtr;
/*
* Utility macros
*/
#define TCL_CMD(a,b,c) \
if (Tcl_CreateObjCommand((a),(b),(c),(ClientData)NULL, NULL) == NULL) \
return TCL_ERROR;
#define OPT_CMP(a,b) \
((a) && (b) && (*(a)==*(b)) && (*(a+1)==*(b+1)) && (!strcmp((a),(b))))
#ifndef TCL_TSD_INIT
#define TCL_TSD_INIT(keyPtr) \
(ThreadSpecificData*)Tcl_GetThreadData((keyPtr),sizeof(ThreadSpecificData))
#endif
/*
* Some functionality within the package depends on the Tcl version. We
* require at least 8.3, and more functionality is available for newer
* versions, so make compatibility defines to compile against 8.3 and work
* fully in 8.4+.
*/
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION == 3)
/* 412 */
typedef int
thread_JoinThread _ANSI_ARGS_((Tcl_ThreadId id, int* result));
/* 413 */
typedef int
thread_IsChannelShared _ANSI_ARGS_((Tcl_Channel channel));
/* 414 */
typedef int
thread_IsChannelRegistered _ANSI_ARGS_((Tcl_Interp* interp,
Tcl_Channel channel));
/* 415 */
typedef void
thread_CutChannel _ANSI_ARGS_((Tcl_Channel channel));
/* 416 */
typedef void
thread_SpliceChannel _ANSI_ARGS_((Tcl_Channel channel));
/* 417 */
typedef void
thread_ClearChannelHandlers _ANSI_ARGS_((Tcl_Channel channel));
/* 418 */
typedef int
thread_IsChannelExisting _ANSI_ARGS_((CONST char* channelName));
/*
* Write up some macros hiding some very hackish pointer arithmetics to get
* at these fields. We assume that pointer to functions are always of the
* same size.
*/
#define STUB_BASE ((char*)(&(tclStubsPtr->tcl_CreateThread))) /* field 393 */
#define procPtrSize (sizeof (Tcl_DriverBlockModeProc *))
#define IDX(n) (((n)-393) * procPtrSize)
#define SLOT(n) (STUB_BASE + IDX(n))
#define Tcl_JoinThread (*((thread_JoinThread**)(SLOT(412))))
#define Tcl_IsChannelShared (*((thread_IsChannelShared**)(SLOT(413))))
#define Tcl_IsChannelRegistered (*((thread_IsChannelRegistered**)(SLOT(414))))
#define Tcl_CutChannel (*((thread_CutChannel**)(SLOT(415))))
#define Tcl_SpliceChannel (*((thread_SpliceChannel**)(SLOT(416))))
#define Tcl_ClearChannelHandlers (*((thread_ClearChannelHandlers**)(SLOT(417))))
#define Tcl_IsChannelExisting (*((thread_IsChannelExisting**)(SLOT(418))))
#endif /* 8.3 compile compatibility */
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
#endif /* _TCL_THREAD_H_ */
|