ceval.h 1.4 KB

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