python 2.7 -> python 3.14
This commit is contained in:
186
extern/include/python/pystate.h
vendored
186
extern/include/python/pystate.h
vendored
@@ -1,4 +1,3 @@
|
||||
|
||||
/* Thread and interpreter state structures and their interfaces */
|
||||
|
||||
|
||||
@@ -8,134 +7,77 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* State shared between threads */
|
||||
|
||||
struct _ts; /* Forward */
|
||||
struct _is; /* Forward */
|
||||
|
||||
typedef struct _is {
|
||||
|
||||
struct _is *next;
|
||||
struct _ts *tstate_head;
|
||||
|
||||
PyObject *modules;
|
||||
PyObject *sysdict;
|
||||
PyObject *builtins;
|
||||
PyObject *modules_reloading;
|
||||
|
||||
PyObject *codec_search_path;
|
||||
PyObject *codec_search_cache;
|
||||
PyObject *codec_error_registry;
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
int dlopenflags;
|
||||
#endif
|
||||
#ifdef WITH_TSC
|
||||
int tscdump;
|
||||
#endif
|
||||
|
||||
} PyInterpreterState;
|
||||
|
||||
|
||||
/* State unique per thread */
|
||||
|
||||
struct _frame; /* Avoid including frameobject.h */
|
||||
|
||||
/* 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
|
||||
#define PyTrace_C_CALL 4
|
||||
#define PyTrace_C_EXCEPTION 5
|
||||
#define PyTrace_C_RETURN 6
|
||||
|
||||
typedef struct _ts {
|
||||
/* See Python/ceval.c for comments explaining most fields */
|
||||
|
||||
struct _ts *next;
|
||||
PyInterpreterState *interp;
|
||||
|
||||
struct _frame *frame;
|
||||
int recursion_depth;
|
||||
/* 'tracing' keeps track of the execution depth when tracing/profiling.
|
||||
This is to prevent the actual trace/profile code from being recorded in
|
||||
the trace/profile. */
|
||||
int tracing;
|
||||
int use_tracing;
|
||||
|
||||
Py_tracefunc c_profilefunc;
|
||||
Py_tracefunc c_tracefunc;
|
||||
PyObject *c_profileobj;
|
||||
PyObject *c_traceobj;
|
||||
|
||||
PyObject *curexc_type;
|
||||
PyObject *curexc_value;
|
||||
PyObject *curexc_traceback;
|
||||
|
||||
PyObject *exc_type;
|
||||
PyObject *exc_value;
|
||||
PyObject *exc_traceback;
|
||||
|
||||
PyObject *dict; /* Stores per-thread state */
|
||||
|
||||
/* tick_counter is incremented whenever the check_interval ticker
|
||||
* reaches zero. The purpose is to give a useful measure of the number
|
||||
* of interpreted bytecode instructions in a given thread. This
|
||||
* extremely lightweight statistic collector may be of interest to
|
||||
* profilers (like psyco.jit()), although nothing in the core uses it.
|
||||
*/
|
||||
int tick_counter;
|
||||
|
||||
int gilstate_counter;
|
||||
|
||||
PyObject *async_exc; /* Asynchronous exception to raise */
|
||||
long thread_id; /* Thread id where this tstate was created */
|
||||
|
||||
int trash_delete_nesting;
|
||||
PyObject *trash_delete_later;
|
||||
|
||||
/* XXX signal handlers should also be here */
|
||||
|
||||
} PyThreadState;
|
||||
|
||||
/* This limitation is for performance and simplicity. If needed it can be
|
||||
removed (with effort). */
|
||||
#define MAX_CO_EXTRA_USERS 255
|
||||
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
|
||||
PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *);
|
||||
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
|
||||
PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
|
||||
#ifdef WITH_THREAD
|
||||
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
||||
/* New in 3.9 */
|
||||
/* Get the current interpreter state.
|
||||
|
||||
Issue a fatal error if there no current Python thread state or no current
|
||||
interpreter. It cannot return NULL.
|
||||
|
||||
The caller must hold the GIL. */
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Get(void);
|
||||
#endif
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03080000
|
||||
/* New in 3.8 */
|
||||
PyAPI_FUNC(PyObject *) PyInterpreterState_GetDict(PyInterpreterState *);
|
||||
#endif
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
|
||||
/* New in 3.7 */
|
||||
PyAPI_FUNC(int64_t) PyInterpreterState_GetID(PyInterpreterState *);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
|
||||
/* State unique per thread */
|
||||
|
||||
/* New in 3.3 */
|
||||
PyAPI_FUNC(int) PyState_AddModule(PyObject*, PyModuleDef*);
|
||||
PyAPI_FUNC(int) PyState_RemoveModule(PyModuleDef*);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject*) PyState_FindModule(PyModuleDef*);
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
|
||||
PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
|
||||
|
||||
/* Get the current thread state.
|
||||
|
||||
When the current thread state is NULL, this issues a fatal error (so that
|
||||
the caller needn't check for NULL).
|
||||
|
||||
The caller must hold the GIL.
|
||||
|
||||
See also PyThreadState_GetUnchecked() and _PyThreadState_GET(). */
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
|
||||
|
||||
// Alias to PyThreadState_Get()
|
||||
#define PyThreadState_GET() PyThreadState_Get()
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
|
||||
PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
|
||||
PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
|
||||
PyAPI_FUNC(int) PyThreadState_SetAsyncExc(unsigned long, PyObject *);
|
||||
|
||||
|
||||
/* Variable and macro for in-line access to current thread state */
|
||||
|
||||
PyAPI_DATA(PyThreadState *) _PyThreadState_Current;
|
||||
|
||||
#ifdef Py_DEBUG
|
||||
#define PyThreadState_GET() PyThreadState_Get()
|
||||
#else
|
||||
#define PyThreadState_GET() (_PyThreadState_Current)
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
||||
/* New in 3.9 */
|
||||
PyAPI_FUNC(PyInterpreterState*) PyThreadState_GetInterpreter(PyThreadState *tstate);
|
||||
PyAPI_FUNC(PyFrameObject*) PyThreadState_GetFrame(PyThreadState *tstate);
|
||||
PyAPI_FUNC(uint64_t) PyThreadState_GetID(PyThreadState *tstate);
|
||||
#endif
|
||||
|
||||
typedef
|
||||
enum {PyGILState_LOCKED, PyGILState_UNLOCKED}
|
||||
PyGILState_STATE;
|
||||
|
||||
|
||||
/* Ensure that the current thread is ready to call the Python
|
||||
C API, regardless of the current state of Python, or of its
|
||||
thread lock. This may be called as many times as desired
|
||||
@@ -177,22 +119,12 @@ PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
|
||||
*/
|
||||
PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
|
||||
|
||||
/* The implementation of sys._current_frames() Returns a dict mapping
|
||||
thread id to that thread's current frame.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
|
||||
|
||||
/* Routines for advanced debuggers, requested by David Beazley.
|
||||
Don't use unless you know what you are doing! */
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
|
||||
|
||||
typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
|
||||
|
||||
/* hook for PyEval_GetFrame(), requested for Psyco */
|
||||
PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_PYSTATE_H
|
||||
# include "cpython/pystate.h"
|
||||
# undef Py_CPYTHON_PYSTATE_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user