Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
pycore_runtime.h64 linesDownload Raw Back to internal
1#ifndef Py_INTERNAL_RUNTIME_H2#define Py_INTERNAL_RUNTIME_H3#ifdef __cplusplus4extern "C" {5#endif6 7#ifndef Py_BUILD_CORE8#  error "this header requires Py_BUILD_CORE define"9#endif10 11#include "pycore_runtime_structs.h" // _PyRuntimeState12 13 14/* API */15 16// Export _PyRuntime for shared extensions which use it in static inline17// functions for best performance, like _Py_IsMainThread() or _Py_ID().18// It's also made accessible for debuggers and profilers.19PyAPI_DATA(_PyRuntimeState) _PyRuntime;20 21extern PyStatus _PyRuntimeState_Init(_PyRuntimeState *runtime);22extern void _PyRuntimeState_Fini(_PyRuntimeState *runtime);23 24#ifdef HAVE_FORK25extern PyStatus _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime);26#endif27 28/* Initialize _PyRuntimeState.29   Return NULL on success, or return an error message on failure. */30extern PyStatus _PyRuntime_Initialize(void);31 32extern void _PyRuntime_Finalize(void);33 34 35static inline PyThreadState*36_PyRuntimeState_GetFinalizing(_PyRuntimeState *runtime) {37    return (PyThreadState*)_Py_atomic_load_ptr_relaxed(&runtime->_finalizing);38}39 40static inline unsigned long41_PyRuntimeState_GetFinalizingID(_PyRuntimeState *runtime) {42    return _Py_atomic_load_ulong_relaxed(&runtime->_finalizing_id);43}44 45static inline void46_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 __cplusplus61}62#endif63#endif /* !Py_INTERNAL_RUNTIME_H */64 
codekingpro/portable-devtools · Team Ai