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