blob: ad914268e022246b7659dab5da4580bcce9873b2 [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
43#define NEXITFUNCS 32
44
Guido van Rossum29e46a91997-08-02 02:56:48 +000045struct _ts; /* Forward */
46struct _is; /* Forward */
47
Guido van Rossuma027efa1997-05-05 20:56:21 +000048typedef struct _is {
49
Guido van Rossum29e46a91997-08-02 02:56:48 +000050 struct _is *next;
51 struct _ts *tstate_head;
52
53 PyObject *modules;
Guido van Rossuma027efa1997-05-05 20:56:21 +000054 PyObject *sysdict;
Guido van Rossum29e46a91997-08-02 02:56:48 +000055 PyObject *builtins;
Guido van Rossuma027efa1997-05-05 20:56:21 +000056
Guido van Rossum29e46a91997-08-02 02:56:48 +000057 int checkinterval;
Guido van Rossuma027efa1997-05-05 20:56:21 +000058
59} PyInterpreterState;
60
61
62/* State unique per thread */
63
64struct _frame; /* Avoid including frameobject.h */
65
66typedef struct _ts {
67
Guido van Rossum29e46a91997-08-02 02:56:48 +000068 struct _ts *next;
69 PyInterpreterState *interp;
Guido van Rossuma027efa1997-05-05 20:56:21 +000070
71 struct _frame *frame;
72 int recursion_depth;
73 int ticker;
74 int tracing;
75
76 PyObject *sys_profilefunc;
77 PyObject *sys_tracefunc;
Guido van Rossuma027efa1997-05-05 20:56:21 +000078
79 PyObject *curexc_type;
80 PyObject *curexc_value;
81 PyObject *curexc_traceback;
82
83 PyObject *exc_type;
84 PyObject *exc_value;
85 PyObject *exc_traceback;
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 Rossum59943ba1997-05-20 22:07:46 +000092PyInterpreterState *PyInterpreterState_New Py_PROTO((void));
Guido van Rossum29e46a91997-08-02 02:56:48 +000093void PyInterpreterState_Clear Py_PROTO((PyInterpreterState *));
Guido van Rossum59943ba1997-05-20 22:07:46 +000094void PyInterpreterState_Delete Py_PROTO((PyInterpreterState *));
Guido van Rossuma027efa1997-05-05 20:56:21 +000095
Guido van Rossum59943ba1997-05-20 22:07:46 +000096PyThreadState *PyThreadState_New Py_PROTO((PyInterpreterState *));
Guido van Rossum29e46a91997-08-02 02:56:48 +000097void PyThreadState_Clear Py_PROTO((PyThreadState *));
Guido van Rossum59943ba1997-05-20 22:07:46 +000098void PyThreadState_Delete Py_PROTO((PyThreadState *));
Guido van Rossuma027efa1997-05-05 20:56:21 +000099
Guido van Rossum59943ba1997-05-20 22:07:46 +0000100PyThreadState *PyThreadState_Get Py_PROTO((void));
101PyThreadState *PyThreadState_Swap Py_PROTO((PyThreadState *));
Guido van Rossuma027efa1997-05-05 20:56:21 +0000102
Guido van Rossuma027efa1997-05-05 20:56:21 +0000103#ifdef __cplusplus
104}
105#endif
106#endif /* !Py_PYSTATE_H */