py-cvs-rel2_1 (Rev 1.2) merge
[python/dscho.git] / Include / pystate.h
blob15a264c6789886e876c4be965ac655a16a85183e
2 /* Thread and interpreter state structures and their interfaces */
5 #ifndef Py_PYSTATE_H
6 #define Py_PYSTATE_H
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
11 /* State shared between threads */
13 struct _ts; /* Forward */
14 struct _is; /* Forward */
16 typedef struct _is {
18 struct _is *next;
19 struct _ts *tstate_head;
21 PyObject *modules;
22 PyObject *sysdict;
23 PyObject *builtins;
25 int checkinterval;
27 } PyInterpreterState;
30 /* State unique per thread */
32 struct _frame; /* Avoid including frameobject.h */
34 /* Py_tracefunc return -1 when raising an exception, or 0 for success. */
35 typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
37 /* The following values are used for 'what' for tracefunc functions: */
38 #define PyTrace_CALL 0
39 #define PyTrace_EXCEPTION 1
40 #define PyTrace_LINE 2
41 #define PyTrace_RETURN 3
43 typedef struct _ts {
45 struct _ts *next;
46 PyInterpreterState *interp;
48 struct _frame *frame;
49 int recursion_depth;
50 int ticker;
51 int tracing;
52 int use_tracing;
54 Py_tracefunc c_profilefunc;
55 Py_tracefunc c_tracefunc;
56 PyObject *c_profileobj;
57 PyObject *c_traceobj;
59 PyObject *curexc_type;
60 PyObject *curexc_value;
61 PyObject *curexc_traceback;
63 PyObject *exc_type;
64 PyObject *exc_value;
65 PyObject *exc_traceback;
67 PyObject *dict;
69 /* XXX signal handlers should also be here */
71 } PyThreadState;
74 DL_IMPORT(PyInterpreterState *) PyInterpreterState_New(void);
75 DL_IMPORT(void) PyInterpreterState_Clear(PyInterpreterState *);
76 DL_IMPORT(void) PyInterpreterState_Delete(PyInterpreterState *);
78 DL_IMPORT(PyThreadState *) PyThreadState_New(PyInterpreterState *);
79 DL_IMPORT(void) PyThreadState_Clear(PyThreadState *);
80 DL_IMPORT(void) PyThreadState_Delete(PyThreadState *);
81 #ifdef WITH_THREAD
82 DL_IMPORT(void) PyThreadState_DeleteCurrent(void);
83 #endif
85 DL_IMPORT(PyThreadState *) PyThreadState_Get(void);
86 DL_IMPORT(PyThreadState *) PyThreadState_Swap(PyThreadState *);
87 DL_IMPORT(PyObject *) PyThreadState_GetDict(void);
90 /* Variable and macro for in-line access to current thread state */
92 extern DL_IMPORT(PyThreadState *) _PyThreadState_Current;
94 #ifdef Py_DEBUG
95 #define PyThreadState_GET() PyThreadState_Get()
96 #else
97 #define PyThreadState_GET() (_PyThreadState_Current)
98 #endif
100 #ifdef __cplusplus
102 #endif
103 #endif /* !Py_PYSTATE_H */