+++ /dev/null
-\r
-/* Thread and interpreter state structures and their interfaces */\r
-\r
-\r
-#ifndef Py_PYSTATE_H\r
-#define Py_PYSTATE_H\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-/* State shared between threads */\r
-\r
-struct _ts; /* Forward */\r
-struct _is; /* Forward */\r
-\r
-typedef struct _is {\r
-\r
- struct _is *next;\r
- struct _ts *tstate_head;\r
-\r
- PyObject *modules;\r
- PyObject *sysdict;\r
- PyObject *builtins;\r
- PyObject *modules_reloading;\r
-\r
- PyObject *codec_search_path;\r
- PyObject *codec_search_cache;\r
- PyObject *codec_error_registry;\r
-\r
-#ifdef HAVE_DLOPEN\r
- int dlopenflags;\r
-#endif\r
-#ifdef WITH_TSC\r
- int tscdump;\r
-#endif\r
-\r
-} PyInterpreterState;\r
-\r
-\r
-/* State unique per thread */\r
-\r
-struct _frame; /* Avoid including frameobject.h */\r
-\r
-/* Py_tracefunc return -1 when raising an exception, or 0 for success. */\r
-typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);\r
-\r
-/* The following values are used for 'what' for tracefunc functions: */\r
-#define PyTrace_CALL 0\r
-#define PyTrace_EXCEPTION 1\r
-#define PyTrace_LINE 2\r
-#define PyTrace_RETURN 3\r
-#define PyTrace_C_CALL 4\r
-#define PyTrace_C_EXCEPTION 5\r
-#define PyTrace_C_RETURN 6\r
-\r
-typedef struct _ts {\r
- /* See Python/ceval.c for comments explaining most fields */\r
-\r
- struct _ts *next;\r
- PyInterpreterState *interp;\r
-\r
- struct _frame *frame;\r
- int recursion_depth;\r
- /* 'tracing' keeps track of the execution depth when tracing/profiling.\r
- This is to prevent the actual trace/profile code from being recorded in\r
- the trace/profile. */\r
- int tracing;\r
- int use_tracing;\r
-\r
- Py_tracefunc c_profilefunc;\r
- Py_tracefunc c_tracefunc;\r
- PyObject *c_profileobj;\r
- PyObject *c_traceobj;\r
-\r
- PyObject *curexc_type;\r
- PyObject *curexc_value;\r
- PyObject *curexc_traceback;\r
-\r
- PyObject *exc_type;\r
- PyObject *exc_value;\r
- PyObject *exc_traceback;\r
-\r
- PyObject *dict; /* Stores per-thread state */\r
-\r
- /* tick_counter is incremented whenever the check_interval ticker\r
- * reaches zero. The purpose is to give a useful measure of the number\r
- * of interpreted bytecode instructions in a given thread. This\r
- * extremely lightweight statistic collector may be of interest to\r
- * profilers (like psyco.jit()), although nothing in the core uses it.\r
- */\r
- int tick_counter;\r
-\r
- int gilstate_counter;\r
-\r
- PyObject *async_exc; /* Asynchronous exception to raise */\r
- long thread_id; /* Thread id where this tstate was created */\r
-\r
- /* XXX signal handlers should also be here */\r
-\r
-} PyThreadState;\r
-\r
-\r
-PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);\r
-PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);\r
-PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);\r
-\r
-PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);\r
-PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);\r
-PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *);\r
-PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);\r
-PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);\r
-#ifdef WITH_THREAD\r
-PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);\r
-PyAPI_FUNC(void) _PyGILState_Reinit(void);\r
-#endif\r
-\r
-PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);\r
-PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);\r
-PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);\r
-PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);\r
-\r
-\r
-/* Variable and macro for in-line access to current thread state */\r
-\r
-PyAPI_DATA(PyThreadState *) _PyThreadState_Current;\r
-\r
-#ifdef Py_DEBUG\r
-#define PyThreadState_GET() PyThreadState_Get()\r
-#else\r
-#define PyThreadState_GET() (_PyThreadState_Current)\r
-#endif\r
-\r
-typedef\r
- enum {PyGILState_LOCKED, PyGILState_UNLOCKED}\r
- PyGILState_STATE;\r
-\r
-/* Ensure that the current thread is ready to call the Python\r
- C API, regardless of the current state of Python, or of its\r
- thread lock. This may be called as many times as desired\r
- by a thread so long as each call is matched with a call to\r
- PyGILState_Release(). In general, other thread-state APIs may\r
- be used between _Ensure() and _Release() calls, so long as the\r
- thread-state is restored to its previous state before the Release().\r
- For example, normal use of the Py_BEGIN_ALLOW_THREADS/\r
- Py_END_ALLOW_THREADS macros are acceptable.\r
-\r
- The return value is an opaque "handle" to the thread state when\r
- PyGILState_Ensure() was called, and must be passed to\r
- PyGILState_Release() to ensure Python is left in the same state. Even\r
- though recursive calls are allowed, these handles can *not* be shared -\r
- each unique call to PyGILState_Ensure must save the handle for its\r
- call to PyGILState_Release.\r
-\r
- When the function returns, the current thread will hold the GIL.\r
-\r
- Failure is a fatal error.\r
-*/\r
-PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);\r
-\r
-/* Release any resources previously acquired. After this call, Python's\r
- state will be the same as it was prior to the corresponding\r
- PyGILState_Ensure() call (but generally this state will be unknown to\r
- the caller, hence the use of the GILState API.)\r
-\r
- Every call to PyGILState_Ensure must be matched by a call to\r
- PyGILState_Release on the same thread.\r
-*/\r
-PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);\r
-\r
-/* Helper/diagnostic function - get the current thread state for\r
- this thread. May return NULL if no GILState API has been used\r
- on the current thread. Note the main thread always has such a\r
- thread-state, even if no auto-thread-state call has been made\r
- on the main thread.\r
-*/\r
-PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);\r
-\r
-/* The implementation of sys._current_frames() Returns a dict mapping\r
- thread id to that thread's current frame.\r
-*/\r
-PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);\r
-\r
-/* Routines for advanced debuggers, requested by David Beazley.\r
- Don't use unless you know what you are doing! */\r
-PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);\r
-PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);\r
-PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);\r
-PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);\r
-\r
-typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);\r
-\r
-/* hook for PyEval_GetFrame(), requested for Psyco */\r
-PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif /* !Py_PYSTATE_H */\r