blob: 57db9b1ebc793585798aacbf20f645bbe74e5840 [file] [log] [blame]
Eric Snow2ebc5ce2017-09-07 23:51:28 -06001#ifndef Py_INTERNAL_CEVAL_H
2#define Py_INTERNAL_CEVAL_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include "pyatomic.h"
8#include "pythread.h"
9
10struct _pending_calls {
11 unsigned long main_thread;
12 PyThread_type_lock lock;
13 /* Request for running pending calls. */
14 _Py_atomic_int calls_to_do;
15 /* Request for looking at the `async_exc` field of the current
16 thread state.
17 Guarded by the GIL. */
18 int async_exc;
19#define NPENDINGCALLS 32
20 struct {
21 int (*func)(void *);
22 void *arg;
23 } calls[NPENDINGCALLS];
24 int first;
25 int last;
26};
27
28#include "internal/gil.h"
29
30struct _ceval_runtime_state {
31 int recursion_limit;
32 int check_recursion_limit;
33 /* Records whether tracing is on for any thread. Counts the number
34 of threads for which tstate->c_tracefunc is non-NULL, so if the
35 value is 0, we know we don't have to check this thread's
36 c_tracefunc. This speeds up the if statement in
37 PyEval_EvalFrameEx() after fast_next_opcode. */
38 int tracing_possible;
39 /* This single variable consolidates all requests to break out of
40 the fast path in the eval loop. */
41 _Py_atomic_int eval_breaker;
42 /* Request for dropping the GIL */
43 _Py_atomic_int gil_drop_request;
44 struct _pending_calls pending;
45 struct _gil_runtime_state gil;
46};
47
48PyAPI_FUNC(void) _PyEval_Initialize(struct _ceval_runtime_state *);
49
50#ifdef __cplusplus
51}
52#endif
53#endif /* !Py_INTERNAL_CEVAL_H */