Move setting of ioready 'wait' earlier in call chain, to
[python/dscho.git] / Include / pystate.h
blob3e5b5b402d1a3962ab48516e966bf7fb5cd14a22
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 #ifdef HAVE_DLOPEN
26 int dlopenflags;
27 #endif
29 } PyInterpreterState;
32 /* State unique per thread */
34 struct _frame; /* Avoid including frameobject.h */
36 /* Py_tracefunc return -1 when raising an exception, or 0 for success. */
37 typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
39 /* The following values are used for 'what' for tracefunc functions: */
40 #define PyTrace_CALL 0
41 #define PyTrace_EXCEPTION 1
42 #define PyTrace_LINE 2
43 #define PyTrace_RETURN 3
45 typedef struct _ts {
47 struct _ts *next;
48 PyInterpreterState *interp;
50 struct _frame *frame;
51 int recursion_depth;
52 int tracing;
53 int use_tracing;
55 Py_tracefunc c_profilefunc;
56 Py_tracefunc c_tracefunc;
57 PyObject *c_profileobj;
58 PyObject *c_traceobj;
60 PyObject *curexc_type;
61 PyObject *curexc_value;
62 PyObject *curexc_traceback;
64 PyObject *exc_type;
65 PyObject *exc_value;
66 PyObject *exc_traceback;
68 PyObject *dict;
70 int tick_counter;
72 /* XXX signal handlers should also be here */
74 } PyThreadState;
77 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
78 PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
79 PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
81 PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
82 PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
83 PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
84 #ifdef WITH_THREAD
85 PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
86 #endif
88 PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
89 PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
90 PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
93 /* Variable and macro for in-line access to current thread state */
95 PyAPI_DATA(PyThreadState *) _PyThreadState_Current;
97 #ifdef Py_DEBUG
98 #define PyThreadState_GET() PyThreadState_Get()
99 #else
100 #define PyThreadState_GET() (_PyThreadState_Current)
101 #endif
103 /* Routines for advanced debuggers, requested by David Beazley.
104 Don't use unless you know what you are doing! */
105 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
106 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
107 PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
108 PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
110 typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
112 /* hook for PyEval_GetFrame(), requested for Psyco */
113 PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
115 #ifdef __cplusplus
117 #endif
118 #endif /* !Py_PYSTATE_H */