blob: f6a26fdb1beb1e8ced5c3956f1ee4e05b69d99cb [file] [log] [blame]
Guido van Rossuma027efa1997-05-05 20:56:21 +00001#ifndef Py_PYSTATE_H
2#define Py_PYSTATE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7/***********************************************************
8Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
9The Netherlands.
10
11 All Rights Reserved
12
13Permission to use, copy, modify, and distribute this software and its
14documentation for any purpose and without fee is hereby granted,
15provided that the above copyright notice appear in all copies and that
16both that copyright notice and this permission notice appear in
17supporting documentation, and that the names of Stichting Mathematisch
18Centrum or CWI or Corporation for National Research Initiatives or
19CNRI not be used in advertising or publicity pertaining to
20distribution of the software without specific, written prior
21permission.
22
23While CWI is the initial source for this software, a modified version
24is made available by the Corporation for National Research Initiatives
25(CNRI) at the Internet address ftp://ftp.python.org.
26
27STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
28REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
29MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
30CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
31DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
32PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
33TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34PERFORMANCE OF THIS SOFTWARE.
35
36******************************************************************/
37
38/* Thread and interpreter state structures and their interfaces */
39
40
41/* State shared between threads */
42
Guido van Rossum29e46a91997-08-02 02:56:48 +000043struct _ts; /* Forward */
44struct _is; /* Forward */
45
Guido van Rossuma027efa1997-05-05 20:56:21 +000046typedef struct _is {
47
Guido van Rossum29e46a91997-08-02 02:56:48 +000048 struct _is *next;
49 struct _ts *tstate_head;
50
51 PyObject *modules;
Guido van Rossuma027efa1997-05-05 20:56:21 +000052 PyObject *sysdict;
Guido van Rossum29e46a91997-08-02 02:56:48 +000053 PyObject *builtins;
Guido van Rossuma027efa1997-05-05 20:56:21 +000054
Guido van Rossum29e46a91997-08-02 02:56:48 +000055 int checkinterval;
Guido van Rossuma027efa1997-05-05 20:56:21 +000056
57} PyInterpreterState;
58
59
60/* State unique per thread */
61
62struct _frame; /* Avoid including frameobject.h */
63
64typedef struct _ts {
65
Guido van Rossum29e46a91997-08-02 02:56:48 +000066 struct _ts *next;
67 PyInterpreterState *interp;
Guido van Rossuma027efa1997-05-05 20:56:21 +000068
69 struct _frame *frame;
70 int recursion_depth;
71 int ticker;
72 int tracing;
73
74 PyObject *sys_profilefunc;
75 PyObject *sys_tracefunc;
Guido van Rossuma027efa1997-05-05 20:56:21 +000076
77 PyObject *curexc_type;
78 PyObject *curexc_value;
79 PyObject *curexc_traceback;
80
81 PyObject *exc_type;
82 PyObject *exc_value;
83 PyObject *exc_traceback;
84
Guido van Rossumee0a63b1998-04-13 20:24:05 +000085 PyObject *dict;
86
Guido van Rossum29e46a91997-08-02 02:56:48 +000087 /* XXX signal handlers should also be here */
Guido van Rossuma027efa1997-05-05 20:56:21 +000088
89} PyThreadState;
90
91
Guido van Rossum43466ec1998-12-04 18:48:25 +000092DL_IMPORT(PyInterpreterState *) PyInterpreterState_New Py_PROTO((void));
93DL_IMPORT(void) PyInterpreterState_Clear Py_PROTO((PyInterpreterState *));
94DL_IMPORT(void) PyInterpreterState_Delete Py_PROTO((PyInterpreterState *));
Guido van Rossuma027efa1997-05-05 20:56:21 +000095
Guido van Rossum43466ec1998-12-04 18:48:25 +000096DL_IMPORT(PyThreadState *) PyThreadState_New Py_PROTO((PyInterpreterState *));
97DL_IMPORT(void) PyThreadState_Clear Py_PROTO((PyThreadState *));
98DL_IMPORT(void) PyThreadState_Delete Py_PROTO((PyThreadState *));
Guido van Rossuma027efa1997-05-05 20:56:21 +000099
Guido van Rossum43466ec1998-12-04 18:48:25 +0000100DL_IMPORT(PyThreadState *) PyThreadState_Get Py_PROTO((void));
101DL_IMPORT(PyThreadState *) PyThreadState_Swap Py_PROTO((PyThreadState *));
102DL_IMPORT(PyObject *) PyThreadState_GetDict Py_PROTO((void));
Guido van Rossuma027efa1997-05-05 20:56:21 +0000103
Guido van Rossum275ea671998-12-21 18:28:10 +0000104
105/* Variable and macro for in-line access to current thread state */
106
107DL_IMPORT(PyThreadState *) _PyThreadState_Current;
108
109#ifdef Py_DEBUG
110#define PyThreadState_GET() PyThreadState_Get()
111#else
112#define PyThreadState_GET() (_PyThreadState_Current)
113#endif
114
Guido van Rossuma027efa1997-05-05 20:56:21 +0000115#ifdef __cplusplus
116}
117#endif
118#endif /* !Py_PYSTATE_H */