blob: fcc0aea13438b79628751dad1cecf8a8e072c7ff [file] [log] [blame]
Guido van Rossuma027efa1997-05-05 20:56:21 +00001/***********************************************************
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00002Copyright (c) 2000, BeOpen.com.
3Copyright (c) 1995-2000, Corporation for National Research Initiatives.
4Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
5All rights reserved.
Guido van Rossuma027efa1997-05-05 20:56:21 +00006
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00007See the file "Misc/COPYRIGHT" for information on usage and
8redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
Guido van Rossuma027efa1997-05-05 20:56:21 +00009******************************************************************/
10
11/* Thread and interpreter state structures and their interfaces */
12
13
Fred Drake5eb6d4e2000-07-08 23:37:28 +000014#ifndef Py_PYSTATE_H
15#define Py_PYSTATE_H
16#ifdef __cplusplus
17extern "C" {
18#endif
19
Guido van Rossuma027efa1997-05-05 20:56:21 +000020/* State shared between threads */
21
Guido van Rossum29e46a91997-08-02 02:56:48 +000022struct _ts; /* Forward */
23struct _is; /* Forward */
24
Guido van Rossuma027efa1997-05-05 20:56:21 +000025typedef struct _is {
26
Fred Drake5eb6d4e2000-07-08 23:37:28 +000027 struct _is *next;
28 struct _ts *tstate_head;
Guido van Rossum29e46a91997-08-02 02:56:48 +000029
Fred Drake5eb6d4e2000-07-08 23:37:28 +000030 PyObject *modules;
31 PyObject *sysdict;
32 PyObject *builtins;
Guido van Rossuma027efa1997-05-05 20:56:21 +000033
Fred Drake5eb6d4e2000-07-08 23:37:28 +000034 int checkinterval;
Guido van Rossuma027efa1997-05-05 20:56:21 +000035
36} PyInterpreterState;
37
38
39/* State unique per thread */
40
41struct _frame; /* Avoid including frameobject.h */
42
43typedef struct _ts {
44
Fred Drake5eb6d4e2000-07-08 23:37:28 +000045 struct _ts *next;
46 PyInterpreterState *interp;
Guido van Rossuma027efa1997-05-05 20:56:21 +000047
Fred Drake5eb6d4e2000-07-08 23:37:28 +000048 struct _frame *frame;
49 int recursion_depth;
50 int ticker;
51 int tracing;
Guido van Rossuma027efa1997-05-05 20:56:21 +000052
Fred Drake5eb6d4e2000-07-08 23:37:28 +000053 PyObject *sys_profilefunc;
54 PyObject *sys_tracefunc;
Guido van Rossuma027efa1997-05-05 20:56:21 +000055
Fred Drake5eb6d4e2000-07-08 23:37:28 +000056 PyObject *curexc_type;
57 PyObject *curexc_value;
58 PyObject *curexc_traceback;
Guido van Rossuma027efa1997-05-05 20:56:21 +000059
Fred Drake5eb6d4e2000-07-08 23:37:28 +000060 PyObject *exc_type;
61 PyObject *exc_value;
62 PyObject *exc_traceback;
Guido van Rossuma027efa1997-05-05 20:56:21 +000063
Fred Drake5eb6d4e2000-07-08 23:37:28 +000064 PyObject *dict;
Guido van Rossumee0a63b1998-04-13 20:24:05 +000065
Fred Drake5eb6d4e2000-07-08 23:37:28 +000066 /* XXX signal handlers should also be here */
Guido van Rossuma027efa1997-05-05 20:56:21 +000067
68} PyThreadState;
69
70
Fred Drake5eb6d4e2000-07-08 23:37:28 +000071DL_IMPORT(PyInterpreterState *) PyInterpreterState_New(void);
72DL_IMPORT(void) PyInterpreterState_Clear(PyInterpreterState *);
73DL_IMPORT(void) PyInterpreterState_Delete(PyInterpreterState *);
Guido van Rossuma027efa1997-05-05 20:56:21 +000074
Fred Drake5eb6d4e2000-07-08 23:37:28 +000075DL_IMPORT(PyThreadState *) PyThreadState_New(PyInterpreterState *);
76DL_IMPORT(void) PyThreadState_Clear(PyThreadState *);
77DL_IMPORT(void) PyThreadState_Delete(PyThreadState *);
Guido van Rossuma027efa1997-05-05 20:56:21 +000078
Fred Drake5eb6d4e2000-07-08 23:37:28 +000079DL_IMPORT(PyThreadState *) PyThreadState_Get(void);
80DL_IMPORT(PyThreadState *) PyThreadState_Swap(PyThreadState *);
81DL_IMPORT(PyObject *) PyThreadState_GetDict(void);
Guido van Rossuma027efa1997-05-05 20:56:21 +000082
Guido van Rossum275ea671998-12-21 18:28:10 +000083
84/* Variable and macro for in-line access to current thread state */
85
Guido van Rossuma8b47fe1998-12-21 20:21:19 +000086extern DL_IMPORT(PyThreadState *) _PyThreadState_Current;
Guido van Rossum275ea671998-12-21 18:28:10 +000087
88#ifdef Py_DEBUG
89#define PyThreadState_GET() PyThreadState_Get()
90#else
91#define PyThreadState_GET() (_PyThreadState_Current)
92#endif
93
Guido van Rossuma027efa1997-05-05 20:56:21 +000094#ifdef __cplusplus
95}
96#endif
97#endif /* !Py_PYSTATE_H */