Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/python3.14/internal/pycore_runtime.h
1 #ifndef Py_INTERNAL_RUNTIME_H 2 #define Py_INTERNAL_RUNTIME_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #ifndef Py_BUILD_CORE 8 # error "this header requires Py_BUILD_CORE define" 9 #endif 10 11 #include "pycore_runtime_structs.h" // _PyRuntimeState 12 13 14 /* API */ 15 16 // Export _PyRuntime for shared extensions which use it in static inline 17 // functions for best performance, like _Py_IsMainThread() or _Py_ID(). 18 // It's also made accessible for debuggers and profilers. 19 PyAPI_DATA(_PyRuntimeState) _PyRuntime; 20 21 extern PyStatus _PyRuntimeState_Init(_PyRuntimeState *runtime); 22 extern void _PyRuntimeState_Fini(_PyRuntimeState *runtime); 23 24 #ifdef HAVE_FORK 25 extern PyStatus _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime); 26 #endif 27 28 /* Initialize _PyRuntimeState. 29 Return NULL on success, or return an error message on failure. */ 30 extern PyStatus _PyRuntime_Initialize(void); 31 32 extern void _PyRuntime_Finalize(void); 33 34 35 static inline PyThreadState* 36 _PyRuntimeState_GetFinalizing(_PyRuntimeState *runtime) { 37 return (PyThreadState*)_Py_atomic_load_ptr_relaxed(&runtime->_finalizing); 38 } 39 40 static inline unsigned long 41 _PyRuntimeState_GetFinalizingID(_PyRuntimeState *runtime) { 42 return _Py_atomic_load_ulong_relaxed(&runtime->_finalizing_id); 43 } 44 45 static inline void 46 _PyRuntimeState_SetFinalizing(_PyRuntimeState *runtime, PyThreadState *tstate) { 47 _Py_atomic_store_ptr_relaxed(&runtime->_finalizing, tstate); 48 if (tstate == NULL) { 49 _Py_atomic_store_ulong_relaxed(&runtime->_finalizing_id, 0); 50 } 51 else { 52 // XXX Re-enable this assert once gh-109860 is fixed. 53 //assert(tstate->thread_id == PyThread_get_thread_ident()); 54 _Py_atomic_store_ulong_relaxed(&runtime->_finalizing_id, 55 tstate->thread_id); 56 } 57 } 58 59 60 #ifdef __cplusplus 61 } 62 #endif 63 #endif /* !Py_INTERNAL_RUNTIME_H */