Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/python3....
File: pystate.h
[0] Fix | Delete
/* Thread and interpreter state structures and their interfaces */
[1] Fix | Delete
[2] Fix | Delete
[3] Fix | Delete
#ifndef Py_PYSTATE_H
[4] Fix | Delete
#define Py_PYSTATE_H
[5] Fix | Delete
#ifdef __cplusplus
[6] Fix | Delete
extern "C" {
[7] Fix | Delete
#endif
[8] Fix | Delete
[9] Fix | Delete
/* This limitation is for performance and simplicity. If needed it can be
[10] Fix | Delete
removed (with effort). */
[11] Fix | Delete
#define MAX_CO_EXTRA_USERS 255
[12] Fix | Delete
[13] Fix | Delete
/* State shared between threads */
[14] Fix | Delete
[15] Fix | Delete
struct _ts; /* Forward */
[16] Fix | Delete
struct _is; /* Forward */
[17] Fix | Delete
struct _frame; /* Forward declaration for PyFrameObject. */
[18] Fix | Delete
[19] Fix | Delete
#ifdef Py_LIMITED_API
[20] Fix | Delete
typedef struct _is PyInterpreterState;
[21] Fix | Delete
#else
[22] Fix | Delete
typedef PyObject* (*_PyFrameEvalFunction)(struct _frame *, int);
[23] Fix | Delete
[24] Fix | Delete
typedef struct _is {
[25] Fix | Delete
[26] Fix | Delete
struct _is *next;
[27] Fix | Delete
struct _ts *tstate_head;
[28] Fix | Delete
[29] Fix | Delete
PyObject *modules;
[30] Fix | Delete
PyObject *modules_by_index;
[31] Fix | Delete
PyObject *sysdict;
[32] Fix | Delete
PyObject *builtins;
[33] Fix | Delete
PyObject *importlib;
[34] Fix | Delete
[35] Fix | Delete
PyObject *codec_search_path;
[36] Fix | Delete
PyObject *codec_search_cache;
[37] Fix | Delete
PyObject *codec_error_registry;
[38] Fix | Delete
int codecs_initialized;
[39] Fix | Delete
int fscodec_initialized;
[40] Fix | Delete
[41] Fix | Delete
#ifdef HAVE_DLOPEN
[42] Fix | Delete
int dlopenflags;
[43] Fix | Delete
#endif
[44] Fix | Delete
[45] Fix | Delete
PyObject *builtins_copy;
[46] Fix | Delete
PyObject *import_func;
[47] Fix | Delete
/* Initialized to PyEval_EvalFrameDefault(). */
[48] Fix | Delete
_PyFrameEvalFunction eval_frame;
[49] Fix | Delete
} PyInterpreterState;
[50] Fix | Delete
#endif
[51] Fix | Delete
[52] Fix | Delete
typedef struct _co_extra_state {
[53] Fix | Delete
struct _co_extra_state *next;
[54] Fix | Delete
PyInterpreterState* interp;
[55] Fix | Delete
[56] Fix | Delete
Py_ssize_t co_extra_user_count;
[57] Fix | Delete
freefunc co_extra_freefuncs[MAX_CO_EXTRA_USERS];
[58] Fix | Delete
} __PyCodeExtraState;
[59] Fix | Delete
[60] Fix | Delete
/* This is temporary for backwards compat in 3.6 and will be removed in 3.7 */
[61] Fix | Delete
__PyCodeExtraState* __PyCodeExtraState_Get(void);
[62] Fix | Delete
[63] Fix | Delete
/* State unique per thread */
[64] Fix | Delete
[65] Fix | Delete
#ifndef Py_LIMITED_API
[66] Fix | Delete
/* Py_tracefunc return -1 when raising an exception, or 0 for success. */
[67] Fix | Delete
typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
[68] Fix | Delete
[69] Fix | Delete
/* The following values are used for 'what' for tracefunc functions: */
[70] Fix | Delete
#define PyTrace_CALL 0
[71] Fix | Delete
#define PyTrace_EXCEPTION 1
[72] Fix | Delete
#define PyTrace_LINE 2
[73] Fix | Delete
#define PyTrace_RETURN 3
[74] Fix | Delete
#define PyTrace_C_CALL 4
[75] Fix | Delete
#define PyTrace_C_EXCEPTION 5
[76] Fix | Delete
#define PyTrace_C_RETURN 6
[77] Fix | Delete
#endif
[78] Fix | Delete
[79] Fix | Delete
#ifdef Py_LIMITED_API
[80] Fix | Delete
typedef struct _ts PyThreadState;
[81] Fix | Delete
#else
[82] Fix | Delete
typedef struct _ts {
[83] Fix | Delete
/* See Python/ceval.c for comments explaining most fields */
[84] Fix | Delete
[85] Fix | Delete
struct _ts *prev;
[86] Fix | Delete
struct _ts *next;
[87] Fix | Delete
PyInterpreterState *interp;
[88] Fix | Delete
[89] Fix | Delete
struct _frame *frame;
[90] Fix | Delete
int recursion_depth;
[91] Fix | Delete
char overflowed; /* The stack has overflowed. Allow 50 more calls
[92] Fix | Delete
to handle the runtime error. */
[93] Fix | Delete
char recursion_critical; /* The current calls must not cause
[94] Fix | Delete
a stack overflow. */
[95] Fix | Delete
/* 'tracing' keeps track of the execution depth when tracing/profiling.
[96] Fix | Delete
This is to prevent the actual trace/profile code from being recorded in
[97] Fix | Delete
the trace/profile. */
[98] Fix | Delete
int tracing;
[99] Fix | Delete
int use_tracing;
[100] Fix | Delete
[101] Fix | Delete
Py_tracefunc c_profilefunc;
[102] Fix | Delete
Py_tracefunc c_tracefunc;
[103] Fix | Delete
PyObject *c_profileobj;
[104] Fix | Delete
PyObject *c_traceobj;
[105] Fix | Delete
[106] Fix | Delete
PyObject *curexc_type;
[107] Fix | Delete
PyObject *curexc_value;
[108] Fix | Delete
PyObject *curexc_traceback;
[109] Fix | Delete
[110] Fix | Delete
PyObject *exc_type;
[111] Fix | Delete
PyObject *exc_value;
[112] Fix | Delete
PyObject *exc_traceback;
[113] Fix | Delete
[114] Fix | Delete
PyObject *dict; /* Stores per-thread state */
[115] Fix | Delete
[116] Fix | Delete
int gilstate_counter;
[117] Fix | Delete
[118] Fix | Delete
PyObject *async_exc; /* Asynchronous exception to raise */
[119] Fix | Delete
long thread_id; /* Thread id where this tstate was created */
[120] Fix | Delete
[121] Fix | Delete
int trash_delete_nesting;
[122] Fix | Delete
PyObject *trash_delete_later;
[123] Fix | Delete
[124] Fix | Delete
/* Called when a thread state is deleted normally, but not when it
[125] Fix | Delete
* is destroyed after fork().
[126] Fix | Delete
* Pain: to prevent rare but fatal shutdown errors (issue 18808),
[127] Fix | Delete
* Thread.join() must wait for the join'ed thread's tstate to be unlinked
[128] Fix | Delete
* from the tstate chain. That happens at the end of a thread's life,
[129] Fix | Delete
* in pystate.c.
[130] Fix | Delete
* The obvious way doesn't quite work: create a lock which the tstate
[131] Fix | Delete
* unlinking code releases, and have Thread.join() wait to acquire that
[132] Fix | Delete
* lock. The problem is that we _are_ at the end of the thread's life:
[133] Fix | Delete
* if the thread holds the last reference to the lock, decref'ing the
[134] Fix | Delete
* lock will delete the lock, and that may trigger arbitrary Python code
[135] Fix | Delete
* if there's a weakref, with a callback, to the lock. But by this time
[136] Fix | Delete
* _PyThreadState_Current is already NULL, so only the simplest of C code
[137] Fix | Delete
* can be allowed to run (in particular it must not be possible to
[138] Fix | Delete
* release the GIL).
[139] Fix | Delete
* So instead of holding the lock directly, the tstate holds a weakref to
[140] Fix | Delete
* the lock: that's the value of on_delete_data below. Decref'ing a
[141] Fix | Delete
* weakref is harmless.
[142] Fix | Delete
* on_delete points to _threadmodule.c's static release_sentinel() function.
[143] Fix | Delete
* After the tstate is unlinked, release_sentinel is called with the
[144] Fix | Delete
* weakref-to-lock (on_delete_data) argument, and release_sentinel releases
[145] Fix | Delete
* the indirectly held lock.
[146] Fix | Delete
*/
[147] Fix | Delete
void (*on_delete)(void *);
[148] Fix | Delete
void *on_delete_data;
[149] Fix | Delete
[150] Fix | Delete
PyObject *coroutine_wrapper;
[151] Fix | Delete
int in_coroutine_wrapper;
[152] Fix | Delete
[153] Fix | Delete
/* Now used from PyInterpreterState, kept here for ABI
[154] Fix | Delete
compatibility with PyThreadState */
[155] Fix | Delete
Py_ssize_t _preserve_36_ABI_1;
[156] Fix | Delete
freefunc _preserve_36_ABI_2[MAX_CO_EXTRA_USERS];
[157] Fix | Delete
[158] Fix | Delete
PyObject *async_gen_firstiter;
[159] Fix | Delete
PyObject *async_gen_finalizer;
[160] Fix | Delete
[161] Fix | Delete
/* XXX signal handlers should also be here */
[162] Fix | Delete
[163] Fix | Delete
} PyThreadState;
[164] Fix | Delete
#endif
[165] Fix | Delete
[166] Fix | Delete
[167] Fix | Delete
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
[168] Fix | Delete
PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
[169] Fix | Delete
PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
[170] Fix | Delete
#ifndef Py_LIMITED_API
[171] Fix | Delete
PyAPI_FUNC(int) _PyState_AddModule(PyObject*, struct PyModuleDef*);
[172] Fix | Delete
#endif /* !Py_LIMITED_API */
[173] Fix | Delete
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
[174] Fix | Delete
/* New in 3.3 */
[175] Fix | Delete
PyAPI_FUNC(int) PyState_AddModule(PyObject*, struct PyModuleDef*);
[176] Fix | Delete
PyAPI_FUNC(int) PyState_RemoveModule(struct PyModuleDef*);
[177] Fix | Delete
#endif
[178] Fix | Delete
PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*);
[179] Fix | Delete
#ifndef Py_LIMITED_API
[180] Fix | Delete
PyAPI_FUNC(void) _PyState_ClearModules(void);
[181] Fix | Delete
#endif
[182] Fix | Delete
[183] Fix | Delete
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
[184] Fix | Delete
#ifndef Py_LIMITED_API
[185] Fix | Delete
PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
[186] Fix | Delete
PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *);
[187] Fix | Delete
#endif /* !Py_LIMITED_API */
[188] Fix | Delete
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
[189] Fix | Delete
PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
[190] Fix | Delete
#ifndef Py_LIMITED_API
[191] Fix | Delete
PyAPI_FUNC(void) _PyThreadState_DeleteExcept(PyThreadState *tstate);
[192] Fix | Delete
#endif /* !Py_LIMITED_API */
[193] Fix | Delete
#ifdef WITH_THREAD
[194] Fix | Delete
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
[195] Fix | Delete
#ifndef Py_LIMITED_API
[196] Fix | Delete
PyAPI_FUNC(void) _PyGILState_Reinit(void);
[197] Fix | Delete
#endif /* !Py_LIMITED_API */
[198] Fix | Delete
#endif
[199] Fix | Delete
[200] Fix | Delete
/* Return the current thread state. The global interpreter lock must be held.
[201] Fix | Delete
* When the current thread state is NULL, this issues a fatal error (so that
[202] Fix | Delete
* the caller needn't check for NULL). */
[203] Fix | Delete
PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
[204] Fix | Delete
[205] Fix | Delete
#ifndef Py_LIMITED_API
[206] Fix | Delete
/* Similar to PyThreadState_Get(), but don't issue a fatal error
[207] Fix | Delete
* if it is NULL. */
[208] Fix | Delete
PyAPI_FUNC(PyThreadState *) _PyThreadState_UncheckedGet(void);
[209] Fix | Delete
#endif /* !Py_LIMITED_API */
[210] Fix | Delete
[211] Fix | Delete
PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
[212] Fix | Delete
PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
[213] Fix | Delete
PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
[214] Fix | Delete
[215] Fix | Delete
[216] Fix | Delete
/* Variable and macro for in-line access to current thread state */
[217] Fix | Delete
[218] Fix | Delete
/* Assuming the current thread holds the GIL, this is the
[219] Fix | Delete
PyThreadState for the current thread. */
[220] Fix | Delete
#ifdef Py_BUILD_CORE
[221] Fix | Delete
PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
[222] Fix | Delete
# define PyThreadState_GET() \
[223] Fix | Delete
((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
[224] Fix | Delete
#else
[225] Fix | Delete
# define PyThreadState_GET() PyThreadState_Get()
[226] Fix | Delete
#endif
[227] Fix | Delete
[228] Fix | Delete
typedef
[229] Fix | Delete
enum {PyGILState_LOCKED, PyGILState_UNLOCKED}
[230] Fix | Delete
PyGILState_STATE;
[231] Fix | Delete
[232] Fix | Delete
#ifdef WITH_THREAD
[233] Fix | Delete
[234] Fix | Delete
/* Ensure that the current thread is ready to call the Python
[235] Fix | Delete
C API, regardless of the current state of Python, or of its
[236] Fix | Delete
thread lock. This may be called as many times as desired
[237] Fix | Delete
by a thread so long as each call is matched with a call to
[238] Fix | Delete
PyGILState_Release(). In general, other thread-state APIs may
[239] Fix | Delete
be used between _Ensure() and _Release() calls, so long as the
[240] Fix | Delete
thread-state is restored to its previous state before the Release().
[241] Fix | Delete
For example, normal use of the Py_BEGIN_ALLOW_THREADS/
[242] Fix | Delete
Py_END_ALLOW_THREADS macros are acceptable.
[243] Fix | Delete
[244] Fix | Delete
The return value is an opaque "handle" to the thread state when
[245] Fix | Delete
PyGILState_Ensure() was called, and must be passed to
[246] Fix | Delete
PyGILState_Release() to ensure Python is left in the same state. Even
[247] Fix | Delete
though recursive calls are allowed, these handles can *not* be shared -
[248] Fix | Delete
each unique call to PyGILState_Ensure must save the handle for its
[249] Fix | Delete
call to PyGILState_Release.
[250] Fix | Delete
[251] Fix | Delete
When the function returns, the current thread will hold the GIL.
[252] Fix | Delete
[253] Fix | Delete
Failure is a fatal error.
[254] Fix | Delete
*/
[255] Fix | Delete
PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);
[256] Fix | Delete
[257] Fix | Delete
/* Release any resources previously acquired. After this call, Python's
[258] Fix | Delete
state will be the same as it was prior to the corresponding
[259] Fix | Delete
PyGILState_Ensure() call (but generally this state will be unknown to
[260] Fix | Delete
the caller, hence the use of the GILState API.)
[261] Fix | Delete
[262] Fix | Delete
Every call to PyGILState_Ensure must be matched by a call to
[263] Fix | Delete
PyGILState_Release on the same thread.
[264] Fix | Delete
*/
[265] Fix | Delete
PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
[266] Fix | Delete
[267] Fix | Delete
/* Helper/diagnostic function - get the current thread state for
[268] Fix | Delete
this thread. May return NULL if no GILState API has been used
[269] Fix | Delete
on the current thread. Note that the main thread always has such a
[270] Fix | Delete
thread-state, even if no auto-thread-state call has been made
[271] Fix | Delete
on the main thread.
[272] Fix | Delete
*/
[273] Fix | Delete
PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
[274] Fix | Delete
[275] Fix | Delete
#ifndef Py_LIMITED_API
[276] Fix | Delete
/* Issue #26558: Flag to disable PyGILState_Check().
[277] Fix | Delete
If set to non-zero, PyGILState_Check() always return 1. */
[278] Fix | Delete
PyAPI_DATA(int) _PyGILState_check_enabled;
[279] Fix | Delete
[280] Fix | Delete
/* Helper/diagnostic function - return 1 if the current thread
[281] Fix | Delete
currently holds the GIL, 0 otherwise.
[282] Fix | Delete
[283] Fix | Delete
The function returns 1 if _PyGILState_check_enabled is non-zero. */
[284] Fix | Delete
PyAPI_FUNC(int) PyGILState_Check(void);
[285] Fix | Delete
[286] Fix | Delete
/* Unsafe function to get the single PyInterpreterState used by this process'
[287] Fix | Delete
GILState implementation.
[288] Fix | Delete
[289] Fix | Delete
Return NULL before _PyGILState_Init() is called and after _PyGILState_Fini()
[290] Fix | Delete
is called. */
[291] Fix | Delete
PyAPI_FUNC(PyInterpreterState *) _PyGILState_GetInterpreterStateUnsafe(void);
[292] Fix | Delete
#endif
[293] Fix | Delete
[294] Fix | Delete
#endif /* #ifdef WITH_THREAD */
[295] Fix | Delete
[296] Fix | Delete
/* The implementation of sys._current_frames() Returns a dict mapping
[297] Fix | Delete
thread id to that thread's current frame.
[298] Fix | Delete
*/
[299] Fix | Delete
#ifndef Py_LIMITED_API
[300] Fix | Delete
PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
[301] Fix | Delete
#endif
[302] Fix | Delete
[303] Fix | Delete
/* Routines for advanced debuggers, requested by David Beazley.
[304] Fix | Delete
Don't use unless you know what you are doing! */
[305] Fix | Delete
#ifndef Py_LIMITED_API
[306] Fix | Delete
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
[307] Fix | Delete
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
[308] Fix | Delete
PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
[309] Fix | Delete
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
[310] Fix | Delete
[311] Fix | Delete
typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
[312] Fix | Delete
#endif
[313] Fix | Delete
[314] Fix | Delete
/* hook for PyEval_GetFrame(), requested for Psyco */
[315] Fix | Delete
#ifndef Py_LIMITED_API
[316] Fix | Delete
PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
[317] Fix | Delete
#endif
[318] Fix | Delete
[319] Fix | Delete
#ifdef __cplusplus
[320] Fix | Delete
}
[321] Fix | Delete
#endif
[322] Fix | Delete
#endif /* !Py_PYSTATE_H */
[323] Fix | Delete
[324] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function