Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
pycore_tstate.h94 linesDownload Raw Back to internal
1#ifndef Py_INTERNAL_TSTATE_H2#define Py_INTERNAL_TSTATE_H3#ifdef __cplusplus4extern "C" {5#endif6 7#ifndef Py_BUILD_CORE8#  error "this header requires Py_BUILD_CORE define"9#endif10 11#include "pycore_brc.h"             // struct _brc_thread_state12#include "pycore_freelist_state.h"  // struct _Py_freelists13#include "pycore_mimalloc.h"        // struct _mimalloc_thread_state14#include "pycore_qsbr.h"            // struct qsbr15 16 17#ifdef Py_GIL_DISABLED18struct _gc_thread_state {19    /* Thread-local allocation count. */20    Py_ssize_t alloc_count;21};22#endif23 24// Every PyThreadState is actually allocated as a _PyThreadStateImpl. The25// PyThreadState fields are exposed as part of the C API, although most fields26// are intended to be private. The _PyThreadStateImpl fields not exposed.27typedef struct _PyThreadStateImpl {28    // semi-public fields are in PyThreadState.29    PyThreadState base;30 31    // The reference count field is used to synchronize deallocation of the32    // thread state during runtime finalization.33    Py_ssize_t refcount;34 35    // These are addresses, but we need to convert to ints to avoid UB.36    uintptr_t c_stack_top;37    uintptr_t c_stack_soft_limit;38    uintptr_t c_stack_hard_limit;39 40    PyObject *asyncio_running_loop; // Strong reference41    PyObject *asyncio_running_task; // Strong reference42 43    /* Head of circular linked-list of all tasks which are instances of `asyncio.Task`44       or subclasses of it used in `asyncio.all_tasks`.45    */46    struct llist_node asyncio_tasks_head;47    struct _qsbr_thread_state *qsbr;  // only used by free-threaded build48    struct llist_node mem_free_queue; // delayed free queue49 50#ifdef Py_GIL_DISABLED51    // Stack references for the current thread that exist on the C stack52    struct _PyCStackRef *c_stack_refs;53    struct _gc_thread_state gc;54    struct _mimalloc_thread_state mimalloc;55    struct _Py_freelists freelists;56    struct _brc_thread_state brc;57    struct {58        // The per-thread refcounts59        Py_ssize_t *values;60 61        // Size of the refcounts array.62        Py_ssize_t size;63 64        // If set, don't use per-thread refcounts65        int is_finalized;66    } refcounts;67 68    // Index to use to retrieve thread-local bytecode for this thread69    int32_t tlbc_index;70 71    // When >1, code objects do not immortalize their non-string constants.72    int suppress_co_const_immortalization;73#endif74 75#if defined(Py_REF_DEBUG) && defined(Py_GIL_DISABLED)76    Py_ssize_t reftotal;  // this thread's total refcount operations77#endif78 79    // PyUnstable_ThreadState_ResetStackProtection() values80    uintptr_t c_stack_init_base;81    uintptr_t c_stack_init_top;82 83#ifdef Py_GIL_DISABLED84    // gh-144438: Add padding to ensure that the fields above don't share a85    // cache line with other allocations.86    char __padding[64];87#endif88} _PyThreadStateImpl;89 90#ifdef __cplusplus91}92#endif93#endif /* !Py_INTERNAL_TSTATE_H */94 
codekingpro/portable-devtools · Team Ai