1/*
2 * --------------------------------------------------------------------------
3 * tclthread.h --
4 *
5 * Global 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 * RCS: @(#) $Id: tclThread.h,v 1.23 2010/03/31 08:50:24 vasiljevic Exp $
14 * ---------------------------------------------------------------------------
15 */
16
17/*
18 * Thread extension version numbers are not stored here
19 * because this isn't a public export file.
20 */
21
22#ifndef _TCL_THREAD_H_
23#define _TCL_THREAD_H_
24
25#include <tcl.h>
26#include <stdlib.h> /* For strtoul */
27#include <string.h> /* For memset and friends */
28
29#undef  TCL_STORAGE_CLASS
30#define TCL_STORAGE_CLASS DLLEXPORT
31
32/*
33 * For linking against AOLserver require V4 at least
34 */
35
36#ifdef NS_AOLSERVER
37# include <ns.h>
38# if !defined(NS_MAJOR_VERSION) || NS_MAJOR_VERSION < 4
39#  error "unsupported AOLserver version"
40# endif
41#endif
42
43/*
44 * Allow for some command names customization.
45 * Only thread:: and tpool:: are handled here.
46 * Shared variable commands are more complicated.
47 * Look into the threadSvCmd.h for more info.
48 */
49
50#define THREAD_CMD_PREFIX "thread::"
51#define TPOOL_CMD_PREFIX  "tpool::"
52
53/*
54 * Exported from threadCmd.c file.
55 */
56
57EXTERN int Thread_Init       _ANSI_ARGS_((Tcl_Interp *interp));
58EXTERN int Thread_SafeInit   _ANSI_ARGS_((Tcl_Interp *interp));
59EXTERN int Thread_Unload     _ANSI_ARGS_((Tcl_Interp *interp));
60EXTERN int Thread_SafeUnload _ANSI_ARGS_((Tcl_Interp *interp));
61
62/*
63 * Exported from threadSvCmd.c file.
64 */
65
66EXTERN int Sv_Init _ANSI_ARGS_((Tcl_Interp *interp));
67
68/*
69 * Exported from threadSpCmd.c file.
70 */
71
72EXTERN int Sp_Init _ANSI_ARGS_((Tcl_Interp *interp));
73
74/*
75 * Exported from threadPoolCmd.c file.
76 */
77
78EXTERN int Tpool_Init _ANSI_ARGS_((Tcl_Interp *interp));
79
80/*
81 * Macros for splicing in/out of linked lists
82 */
83
84#define SpliceIn(a,b)                          \
85    (a)->nextPtr = (b);                        \
86    if ((b) != NULL)                           \
87        (b)->prevPtr = (a);                    \
88    (a)->prevPtr = NULL, (b) = (a)
89
90#define SpliceOut(a,b)                         \
91    if ((a)->prevPtr != NULL)                  \
92        (a)->prevPtr->nextPtr = (a)->nextPtr;  \
93    else                                       \
94        (b) = (a)->nextPtr;                    \
95    if ((a)->nextPtr != NULL)                  \
96        (a)->nextPtr->prevPtr = (a)->prevPtr
97
98/*
99 * Utility macros
100 */
101
102#define TCL_CMD(a,b,c) \
103  if (Tcl_CreateObjCommand((a),(b),(c),(ClientData)NULL, NULL) == NULL) \
104    return TCL_ERROR
105
106#define OPT_CMP(a,b) \
107  ((a) && (b) && (*(a)==*(b)) && (*(a+1)==*(b+1)) && (!strcmp((a),(b))))
108
109#ifndef TCL_TSD_INIT
110#define TCL_TSD_INIT(keyPtr) \
111  (ThreadSpecificData*)Tcl_GetThreadData((keyPtr),sizeof(ThreadSpecificData))
112#endif
113
114#undef  TCL_STORAGE_CLASS
115#define TCL_STORAGE_CLASS DLLIMPORT
116
117#endif /* _TCL_THREAD_H_ */
118