| #ifndef Py_INTERNAL_RUNTIME_H |
| #define Py_INTERNAL_RUNTIME_H |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
|
|
| #ifndef Py_BUILD_CORE |
| # error "this header requires Py_BUILD_CORE define" |
| #endif |
|
|
| #include "pycore_atomic.h" |
| #include "pycore_gil.h" |
|
|
| |
|
|
| struct _ceval_runtime_state { |
| |
| |
| |
| |
| _Py_atomic_int signals_pending; |
| #ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS |
| struct _gil_runtime_state gil; |
| #endif |
| }; |
|
|
| |
|
|
| struct _gilstate_runtime_state { |
| |
| |
| int check_enabled; |
| |
| |
| _Py_atomic_address tstate_current; |
| |
| |
| |
| |
| PyInterpreterState *autoInterpreterState; |
| Py_tss_t autoTSSkey; |
| }; |
|
|
| |
|
|
| typedef struct _Py_AuditHookEntry { |
| struct _Py_AuditHookEntry *next; |
| Py_AuditHookFunction hookCFunction; |
| void *userData; |
| } _Py_AuditHookEntry; |
|
|
| struct _Py_unicode_runtime_ids { |
| PyThread_type_lock lock; |
| |
| |
| Py_ssize_t next_index; |
| }; |
|
|
| |
|
|
| typedef struct pyruntimestate { |
| |
| int preinitializing; |
|
|
| |
| int preinitialized; |
|
|
| |
| int core_initialized; |
|
|
| |
| int initialized; |
|
|
| |
| |
| |
| |
| |
| _Py_atomic_address _finalizing; |
|
|
| struct pyinterpreters { |
| PyThread_type_lock mutex; |
| PyInterpreterState *head; |
| PyInterpreterState *main; |
| |
| |
| |
| |
| |
| |
| |
| |
| int64_t next_id; |
| } interpreters; |
| |
| struct _xidregistry { |
| PyThread_type_lock mutex; |
| struct _xidregitem *head; |
| } xidregistry; |
|
|
| unsigned long main_thread; |
|
|
| #define NEXITFUNCS 32 |
| void (*exitfuncs[NEXITFUNCS])(void); |
| int nexitfuncs; |
|
|
| struct _ceval_runtime_state ceval; |
| struct _gilstate_runtime_state gilstate; |
|
|
| PyPreConfig preconfig; |
|
|
| |
| |
| Py_OpenCodeHookFunction open_code_hook; |
| void *open_code_userdata; |
| _Py_AuditHookEntry *audit_hook_head; |
|
|
| struct _Py_unicode_runtime_ids unicode_ids; |
|
|
| |
| } _PyRuntimeState; |
|
|
| #define _PyRuntimeState_INIT \ |
| {.preinitialized = 0, .core_initialized = 0, .initialized = 0} |
| |
|
|
|
|
| PyAPI_DATA(_PyRuntimeState) _PyRuntime; |
|
|
| PyAPI_FUNC(PyStatus) _PyRuntimeState_Init(_PyRuntimeState *runtime); |
| PyAPI_FUNC(void) _PyRuntimeState_Fini(_PyRuntimeState *runtime); |
|
|
| #ifdef HAVE_FORK |
| extern PyStatus _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime); |
| #endif |
|
|
| |
| |
| PyAPI_FUNC(PyStatus) _PyRuntime_Initialize(void); |
|
|
| PyAPI_FUNC(void) _PyRuntime_Finalize(void); |
|
|
|
|
| static inline PyThreadState* |
| _PyRuntimeState_GetFinalizing(_PyRuntimeState *runtime) { |
| return (PyThreadState*)_Py_atomic_load_relaxed(&runtime->_finalizing); |
| } |
|
|
| static inline void |
| _PyRuntimeState_SetFinalizing(_PyRuntimeState *runtime, PyThreadState *tstate) { |
| _Py_atomic_store_relaxed(&runtime->_finalizing, (uintptr_t)tstate); |
| } |
|
|
| #ifdef __cplusplus |
| } |
| #endif |
| #endif |
|
|