Eric Snow | 2ebc5ce | 2017-09-07 23:51:28 -0600 | [diff] [blame] | 1 | #ifndef Py_INTERNAL_CEVAL_H |
| 2 | #define Py_INTERNAL_CEVAL_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
Victor Stinner | 5c75f37 | 2019-04-17 23:02:26 +0200 | [diff] [blame^] | 7 | #ifndef Py_BUILD_CORE |
| 8 | # error "this header requires Py_BUILD_CORE define" |
Victor Stinner | 130893d | 2018-11-09 13:03:37 +0100 | [diff] [blame] | 9 | #endif |
| 10 | |
Victor Stinner | 27e2d1f | 2018-11-01 00:52:28 +0100 | [diff] [blame] | 11 | #include "pycore_atomic.h" |
Eric Snow | 2ebc5ce | 2017-09-07 23:51:28 -0600 | [diff] [blame] | 12 | #include "pythread.h" |
| 13 | |
Eric Snow | b75b1a35 | 2019-04-12 10:20:10 -0600 | [diff] [blame] | 14 | PyAPI_FUNC(void) _Py_FinishPendingCalls(void); |
Eric Snow | 842a2f0 | 2019-03-15 15:47:51 -0600 | [diff] [blame] | 15 | |
Eric Snow | 2ebc5ce | 2017-09-07 23:51:28 -0600 | [diff] [blame] | 16 | struct _pending_calls { |
Eric Snow | 842a2f0 | 2019-03-15 15:47:51 -0600 | [diff] [blame] | 17 | int finishing; |
Eric Snow | 2ebc5ce | 2017-09-07 23:51:28 -0600 | [diff] [blame] | 18 | PyThread_type_lock lock; |
| 19 | /* Request for running pending calls. */ |
| 20 | _Py_atomic_int calls_to_do; |
| 21 | /* Request for looking at the `async_exc` field of the current |
| 22 | thread state. |
| 23 | Guarded by the GIL. */ |
| 24 | int async_exc; |
| 25 | #define NPENDINGCALLS 32 |
| 26 | struct { |
| 27 | int (*func)(void *); |
| 28 | void *arg; |
| 29 | } calls[NPENDINGCALLS]; |
| 30 | int first; |
| 31 | int last; |
| 32 | }; |
| 33 | |
Victor Stinner | 27e2d1f | 2018-11-01 00:52:28 +0100 | [diff] [blame] | 34 | #include "pycore_gil.h" |
Eric Snow | 2ebc5ce | 2017-09-07 23:51:28 -0600 | [diff] [blame] | 35 | |
| 36 | struct _ceval_runtime_state { |
| 37 | int recursion_limit; |
Eric Snow | 2ebc5ce | 2017-09-07 23:51:28 -0600 | [diff] [blame] | 38 | /* Records whether tracing is on for any thread. Counts the number |
| 39 | of threads for which tstate->c_tracefunc is non-NULL, so if the |
| 40 | value is 0, we know we don't have to check this thread's |
| 41 | c_tracefunc. This speeds up the if statement in |
| 42 | PyEval_EvalFrameEx() after fast_next_opcode. */ |
| 43 | int tracing_possible; |
Eric Snow | b75b1a35 | 2019-04-12 10:20:10 -0600 | [diff] [blame] | 44 | /* This single variable consolidates all requests to break out of |
| 45 | the fast path in the eval loop. */ |
| 46 | _Py_atomic_int eval_breaker; |
Eric Snow | 2ebc5ce | 2017-09-07 23:51:28 -0600 | [diff] [blame] | 47 | /* Request for dropping the GIL */ |
| 48 | _Py_atomic_int gil_drop_request; |
Eric Snow | b75b1a35 | 2019-04-12 10:20:10 -0600 | [diff] [blame] | 49 | struct _pending_calls pending; |
Eric Snow | fdf282d | 2019-01-11 14:26:55 -0700 | [diff] [blame] | 50 | /* Request for checking signals. */ |
| 51 | _Py_atomic_int signals_pending; |
Eric Snow | 2ebc5ce | 2017-09-07 23:51:28 -0600 | [diff] [blame] | 52 | struct _gil_runtime_state gil; |
| 53 | }; |
| 54 | |
| 55 | PyAPI_FUNC(void) _PyEval_Initialize(struct _ceval_runtime_state *); |
| 56 | |
| 57 | #ifdef __cplusplus |
| 58 | } |
| 59 | #endif |
| 60 | #endif /* !Py_INTERNAL_CEVAL_H */ |