• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef Py_INTERNAL_CEVAL_H
2 #define Py_INTERNAL_CEVAL_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 #include "pyatomic.h"
8 #include "pythread.h"
9 
10 struct _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 
30 struct _ceval_runtime_state {
31     int recursion_limit;
32     /* Records whether tracing is on for any thread.  Counts the number
33        of threads for which tstate->c_tracefunc is non-NULL, so if the
34        value is 0, we know we don't have to check this thread's
35        c_tracefunc.  This speeds up the if statement in
36        PyEval_EvalFrameEx() after fast_next_opcode. */
37     int tracing_possible;
38     /* This single variable consolidates all requests to break out of
39        the fast path in the eval loop. */
40     _Py_atomic_int eval_breaker;
41     /* Request for dropping the GIL */
42     _Py_atomic_int gil_drop_request;
43     struct _pending_calls pending;
44     struct _gil_runtime_state gil;
45 };
46 
47 PyAPI_FUNC(void) _PyEval_Initialize(struct _ceval_runtime_state *);
48 
49 #ifdef __cplusplus
50 }
51 #endif
52 #endif /* !Py_INTERNAL_CEVAL_H */
53