2017-09-08 02:51:28 -03:00
|
|
|
#ifndef Py_INTERNAL_CEVAL_H
|
|
|
|
#define Py_INTERNAL_CEVAL_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-11-09 08:03:37 -04:00
|
|
|
#if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
|
|
|
|
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
|
|
|
|
#endif
|
|
|
|
|
2018-10-31 20:52:28 -03:00
|
|
|
#include "pycore_atomic.h"
|
2017-09-08 02:51:28 -03:00
|
|
|
#include "pythread.h"
|
|
|
|
|
2019-04-12 13:20:10 -03:00
|
|
|
PyAPI_FUNC(void) _Py_FinishPendingCalls(void);
|
2019-03-15 18:47:51 -03:00
|
|
|
|
2017-09-08 02:51:28 -03:00
|
|
|
struct _pending_calls {
|
2019-03-15 18:47:51 -03:00
|
|
|
int finishing;
|
2017-09-08 02:51:28 -03:00
|
|
|
PyThread_type_lock lock;
|
|
|
|
/* Request for running pending calls. */
|
|
|
|
_Py_atomic_int calls_to_do;
|
|
|
|
/* Request for looking at the `async_exc` field of the current
|
|
|
|
thread state.
|
|
|
|
Guarded by the GIL. */
|
|
|
|
int async_exc;
|
|
|
|
#define NPENDINGCALLS 32
|
|
|
|
struct {
|
|
|
|
int (*func)(void *);
|
|
|
|
void *arg;
|
|
|
|
} calls[NPENDINGCALLS];
|
|
|
|
int first;
|
|
|
|
int last;
|
|
|
|
};
|
|
|
|
|
2018-10-31 20:52:28 -03:00
|
|
|
#include "pycore_gil.h"
|
2017-09-08 02:51:28 -03:00
|
|
|
|
|
|
|
struct _ceval_runtime_state {
|
|
|
|
int recursion_limit;
|
|
|
|
/* Records whether tracing is on for any thread. Counts the number
|
|
|
|
of threads for which tstate->c_tracefunc is non-NULL, so if the
|
|
|
|
value is 0, we know we don't have to check this thread's
|
|
|
|
c_tracefunc. This speeds up the if statement in
|
|
|
|
PyEval_EvalFrameEx() after fast_next_opcode. */
|
|
|
|
int tracing_possible;
|
2019-04-12 13:20:10 -03:00
|
|
|
/* This single variable consolidates all requests to break out of
|
|
|
|
the fast path in the eval loop. */
|
|
|
|
_Py_atomic_int eval_breaker;
|
2017-09-08 02:51:28 -03:00
|
|
|
/* Request for dropping the GIL */
|
|
|
|
_Py_atomic_int gil_drop_request;
|
2019-04-12 13:20:10 -03:00
|
|
|
struct _pending_calls pending;
|
2019-01-11 17:26:55 -04:00
|
|
|
/* Request for checking signals. */
|
|
|
|
_Py_atomic_int signals_pending;
|
2017-09-08 02:51:28 -03:00
|
|
|
struct _gil_runtime_state gil;
|
|
|
|
};
|
|
|
|
|
|
|
|
PyAPI_FUNC(void) _PyEval_Initialize(struct _ceval_runtime_state *);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_INTERNAL_CEVAL_H */
|