Path: blob/main/Include/internal/pycore_ceval_state.h
12 views
#ifndef Py_INTERNAL_CEVAL_STATE_H1#define Py_INTERNAL_CEVAL_STATE_H2#ifdef __cplusplus3extern "C" {4#endif56#ifndef Py_BUILD_CORE7# error "this header requires Py_BUILD_CORE define"8#endif91011#include "pycore_atomic.h" /* _Py_atomic_address */12#include "pycore_gil.h" // struct _gil_runtime_state131415struct _pending_calls {16int busy;17PyThread_type_lock lock;18/* Request for running pending calls. */19_Py_atomic_int calls_to_do;20/* Request for looking at the `async_exc` field of the current21thread state.22Guarded by the GIL. */23int async_exc;24#define NPENDINGCALLS 3225struct _pending_call {26int (*func)(void *);27void *arg;28} calls[NPENDINGCALLS];29int first;30int last;31};3233typedef enum {34PERF_STATUS_FAILED = -1, // Perf trampoline is in an invalid state35PERF_STATUS_NO_INIT = 0, // Perf trampoline is not initialized36PERF_STATUS_OK = 1, // Perf trampoline is ready to be executed37} perf_status_t;383940#ifdef PY_HAVE_PERF_TRAMPOLINE41struct code_arena_st;4243struct trampoline_api_st {44void* (*init_state)(void);45void (*write_state)(void* state, const void *code_addr,46unsigned int code_size, PyCodeObject* code);47int (*free_state)(void* state);48void *state;49};50#endif5152struct _ceval_runtime_state {53struct {54#ifdef PY_HAVE_PERF_TRAMPOLINE55perf_status_t status;56Py_ssize_t extra_code_index;57struct code_arena_st *code_arena;58struct trampoline_api_st trampoline_api;59FILE *map_file;60#else61int _not_used;62#endif63} perf;64/* Request for checking signals. It is shared by all interpreters (see65bpo-40513). Any thread of any interpreter can receive a signal, but only66the main thread of the main interpreter can handle signals: see67_Py_ThreadCanHandleSignals(). */68_Py_atomic_int signals_pending;69/* Pending calls to be made only on the main thread. */70struct _pending_calls pending_mainthread;71};7273#ifdef PY_HAVE_PERF_TRAMPOLINE74# define _PyEval_RUNTIME_PERF_INIT \75{ \76.status = PERF_STATUS_NO_INIT, \77.extra_code_index = -1, \78}79#else80# define _PyEval_RUNTIME_PERF_INIT {0}81#endif828384struct _ceval_state {85/* This single variable consolidates all requests to break out of86the fast path in the eval loop. */87_Py_atomic_int eval_breaker;88/* Request for dropping the GIL */89_Py_atomic_int gil_drop_request;90int recursion_limit;91struct _gil_runtime_state *gil;92int own_gil;93/* The GC is ready to be executed */94_Py_atomic_int gc_scheduled;95struct _pending_calls pending;96};979899#ifdef __cplusplus100}101#endif102#endif /* !Py_INTERNAL_CEVAL_STATE_H */103104105