1997-05-05 17:56:21 -03:00
|
|
|
|
|
|
|
/* Thread and interpreter state structures and their interfaces */
|
|
|
|
|
|
|
|
|
2000-07-08 20:37:28 -03:00
|
|
|
#ifndef Py_PYSTATE_H
|
|
|
|
#define Py_PYSTATE_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
1997-05-05 17:56:21 -03:00
|
|
|
/* State shared between threads */
|
|
|
|
|
1997-08-01 23:56:48 -03:00
|
|
|
struct _ts; /* Forward */
|
|
|
|
struct _is; /* Forward */
|
|
|
|
|
1997-05-05 17:56:21 -03:00
|
|
|
typedef struct _is {
|
|
|
|
|
2000-07-08 20:37:28 -03:00
|
|
|
struct _is *next;
|
|
|
|
struct _ts *tstate_head;
|
1997-05-05 17:56:21 -03:00
|
|
|
|
2000-07-08 20:37:28 -03:00
|
|
|
PyObject *modules;
|
|
|
|
PyObject *sysdict;
|
|
|
|
PyObject *builtins;
|
1997-05-05 17:56:21 -03:00
|
|
|
|
2003-03-18 20:35:36 -04:00
|
|
|
PyObject *codec_search_path;
|
|
|
|
PyObject *codec_search_cache;
|
|
|
|
PyObject *codec_error_registry;
|
|
|
|
|
2001-07-18 13:17:16 -03:00
|
|
|
#ifdef HAVE_DLOPEN
|
|
|
|
int dlopenflags;
|
|
|
|
#endif
|
1997-05-05 17:56:21 -03:00
|
|
|
|
|
|
|
} PyInterpreterState;
|
|
|
|
|
|
|
|
|
|
|
|
/* State unique per thread */
|
|
|
|
|
|
|
|
struct _frame; /* Avoid including frameobject.h */
|
|
|
|
|
2001-06-27 16:18:03 -03:00
|
|
|
/* Py_tracefunc return -1 when raising an exception, or 0 for success. */
|
|
|
|
typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
|
|
|
|
|
|
|
|
/* The following values are used for 'what' for tracefunc functions: */
|
|
|
|
#define PyTrace_CALL 0
|
|
|
|
#define PyTrace_EXCEPTION 1
|
|
|
|
#define PyTrace_LINE 2
|
|
|
|
#define PyTrace_RETURN 3
|
|
|
|
|
1997-05-05 17:56:21 -03:00
|
|
|
typedef struct _ts {
|
|
|
|
|
2000-07-08 20:37:28 -03:00
|
|
|
struct _ts *next;
|
|
|
|
PyInterpreterState *interp;
|
1997-05-05 17:56:21 -03:00
|
|
|
|
2000-07-08 20:37:28 -03:00
|
|
|
struct _frame *frame;
|
|
|
|
int recursion_depth;
|
|
|
|
int tracing;
|
2001-07-03 20:39:52 -03:00
|
|
|
int use_tracing;
|
1997-05-05 17:56:21 -03:00
|
|
|
|
2001-06-27 16:18:03 -03:00
|
|
|
Py_tracefunc c_profilefunc;
|
|
|
|
Py_tracefunc c_tracefunc;
|
|
|
|
PyObject *c_profileobj;
|
|
|
|
PyObject *c_traceobj;
|
1997-05-05 17:56:21 -03:00
|
|
|
|
2000-07-08 20:37:28 -03:00
|
|
|
PyObject *curexc_type;
|
|
|
|
PyObject *curexc_value;
|
|
|
|
PyObject *curexc_traceback;
|
1997-05-05 17:56:21 -03:00
|
|
|
|
2000-07-08 20:37:28 -03:00
|
|
|
PyObject *exc_type;
|
|
|
|
PyObject *exc_value;
|
|
|
|
PyObject *exc_traceback;
|
1997-05-05 17:56:21 -03:00
|
|
|
|
2000-07-08 20:37:28 -03:00
|
|
|
PyObject *dict;
|
1998-04-13 17:24:05 -03:00
|
|
|
|
2002-11-08 08:53:11 -04:00
|
|
|
int tick_counter;
|
|
|
|
|
2000-07-08 20:37:28 -03:00
|
|
|
/* XXX signal handlers should also be here */
|
1997-05-05 17:56:21 -03:00
|
|
|
|
|
|
|
} PyThreadState;
|
|
|
|
|
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
|
|
|
|
PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
|
|
|
|
PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
|
1997-05-05 17:56:21 -03:00
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
|
|
|
|
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
|
|
|
|
PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
|
2001-01-22 21:46:06 -04:00
|
|
|
#ifdef WITH_THREAD
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
|
2001-01-22 21:46:06 -04:00
|
|
|
#endif
|
1997-05-05 17:56:21 -03:00
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
|
|
|
|
PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
|
|
|
|
PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
|
1997-05-05 17:56:21 -03:00
|
|
|
|
1998-12-21 14:28:10 -04:00
|
|
|
|
|
|
|
/* Variable and macro for in-line access to current thread state */
|
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_DATA(PyThreadState *) _PyThreadState_Current;
|
1998-12-21 14:28:10 -04:00
|
|
|
|
|
|
|
#ifdef Py_DEBUG
|
|
|
|
#define PyThreadState_GET() PyThreadState_Get()
|
|
|
|
#else
|
|
|
|
#define PyThreadState_GET() (_PyThreadState_Current)
|
|
|
|
#endif
|
|
|
|
|
2001-07-19 09:19:27 -03:00
|
|
|
/* Routines for advanced debuggers, requested by David Beazley.
|
|
|
|
Don't use unless you know what you are doing! */
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
|
|
|
|
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
|
|
|
|
PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
|
|
|
|
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
|
2001-07-19 09:19:27 -03:00
|
|
|
|
2003-02-19 11:53:17 -04:00
|
|
|
typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
|
|
|
|
|
2002-11-08 08:53:11 -04:00
|
|
|
/* hook for PyEval_GetFrame(), requested for Psyco */
|
2003-02-19 11:53:17 -04:00
|
|
|
PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
|
2002-11-08 08:53:11 -04:00
|
|
|
|
1997-05-05 17:56:21 -03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_PYSTATE_H */
|