File indexing completed on 2025-01-30 10:18:06
0001 #ifndef Py_INTERNAL_CEVAL_STATE_H
0002 #define Py_INTERNAL_CEVAL_STATE_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006
0007 #ifndef Py_BUILD_CORE
0008 # error "this header requires Py_BUILD_CORE define"
0009 #endif
0010
0011
0012 #include "pycore_atomic.h" /* _Py_atomic_address */
0013 #include "pycore_gil.h" // struct _gil_runtime_state
0014
0015
0016 struct _pending_calls {
0017 int busy;
0018 PyThread_type_lock lock;
0019
0020 _Py_atomic_int calls_to_do;
0021
0022
0023
0024 int async_exc;
0025 #define NPENDINGCALLS 32
0026 struct _pending_call {
0027 int (*func)(void *);
0028 void *arg;
0029 } calls[NPENDINGCALLS];
0030 int first;
0031 int last;
0032 };
0033
0034 typedef enum {
0035 PERF_STATUS_FAILED = -1,
0036 PERF_STATUS_NO_INIT = 0,
0037 PERF_STATUS_OK = 1,
0038 } perf_status_t;
0039
0040
0041 #ifdef PY_HAVE_PERF_TRAMPOLINE
0042 struct code_arena_st;
0043
0044 struct trampoline_api_st {
0045 void* (*init_state)(void);
0046 void (*write_state)(void* state, const void *code_addr,
0047 unsigned int code_size, PyCodeObject* code);
0048 int (*free_state)(void* state);
0049 void *state;
0050 };
0051 #endif
0052
0053 struct _ceval_runtime_state {
0054 struct {
0055 #ifdef PY_HAVE_PERF_TRAMPOLINE
0056 perf_status_t status;
0057 Py_ssize_t extra_code_index;
0058 struct code_arena_st *code_arena;
0059 struct trampoline_api_st trampoline_api;
0060 FILE *map_file;
0061 #else
0062 int _not_used;
0063 #endif
0064 } perf;
0065
0066
0067
0068
0069 _Py_atomic_int signals_pending;
0070
0071 struct _pending_calls pending_mainthread;
0072 };
0073
0074 #ifdef PY_HAVE_PERF_TRAMPOLINE
0075 # define _PyEval_RUNTIME_PERF_INIT \
0076 { \
0077 .status = PERF_STATUS_NO_INIT, \
0078 .extra_code_index = -1, \
0079 }
0080 #else
0081 # define _PyEval_RUNTIME_PERF_INIT {0}
0082 #endif
0083
0084
0085 struct _ceval_state {
0086
0087
0088 _Py_atomic_int eval_breaker;
0089
0090 _Py_atomic_int gil_drop_request;
0091 int recursion_limit;
0092 struct _gil_runtime_state *gil;
0093 int own_gil;
0094
0095 _Py_atomic_int gc_scheduled;
0096 struct _pending_calls pending;
0097 };
0098
0099
0100 #ifdef __cplusplus
0101 }
0102 #endif
0103 #endif