|
| 1 | +#ifndef Py_INTERNAL_CEVAL_STATE_H |
| 2 | +#define Py_INTERNAL_CEVAL_STATE_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 | + |
| 12 | +#include "pycore_atomic.h" /* _Py_atomic_address */ |
| 13 | +#include "pycore_gil.h" // struct _gil_runtime_state |
| 14 | + |
| 15 | + |
| 16 | +struct _ceval_runtime_state { |
| 17 | + /* Request for checking signals. It is shared by all interpreters (see |
| 18 | + bpo-40513). Any thread of any interpreter can receive a signal, but only |
| 19 | + the main thread of the main interpreter can handle signals: see |
| 20 | + _Py_ThreadCanHandleSignals(). */ |
| 21 | + _Py_atomic_int signals_pending; |
| 22 | + struct _gil_runtime_state gil; |
| 23 | +}; |
| 24 | + |
| 25 | + |
| 26 | +struct _pending_calls { |
| 27 | + int busy; |
| 28 | + PyThread_type_lock lock; |
| 29 | + /* Request for running pending calls. */ |
| 30 | + _Py_atomic_int calls_to_do; |
| 31 | + /* Request for looking at the `async_exc` field of the current |
| 32 | + thread state. |
| 33 | + Guarded by the GIL. */ |
| 34 | + int async_exc; |
| 35 | +#define NPENDINGCALLS 32 |
| 36 | + struct { |
| 37 | + int (*func)(void *); |
| 38 | + void *arg; |
| 39 | + } calls[NPENDINGCALLS]; |
| 40 | + int first; |
| 41 | + int last; |
| 42 | +}; |
| 43 | + |
| 44 | +struct _ceval_state { |
| 45 | + int recursion_limit; |
| 46 | + /* This single variable consolidates all requests to break out of |
| 47 | + the fast path in the eval loop. */ |
| 48 | + _Py_atomic_int eval_breaker; |
| 49 | + /* Request for dropping the GIL */ |
| 50 | + _Py_atomic_int gil_drop_request; |
| 51 | + /* The GC is ready to be executed */ |
| 52 | + _Py_atomic_int gc_scheduled; |
| 53 | + struct _pending_calls pending; |
| 54 | +}; |
| 55 | + |
| 56 | + |
| 57 | +#ifdef __cplusplus |
| 58 | +} |
| 59 | +#endif |
| 60 | +#endif /* !Py_INTERNAL_CEVAL_STATE_H */ |
0 commit comments