2017-09-08 05:51:28 +00:00
|
|
|
#ifndef Py_INTERNAL_CEVAL_H
|
|
|
|
#define Py_INTERNAL_CEVAL_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-04-17 21:02:26 +00:00
|
|
|
#ifndef Py_BUILD_CORE
|
|
|
|
# error "this header requires Py_BUILD_CORE define"
|
2018-11-09 12:03:37 +00:00
|
|
|
#endif
|
|
|
|
|
2019-10-02 21:51:20 +00:00
|
|
|
/* Forward declarations */
|
2019-10-04 00:21:05 +00:00
|
|
|
struct pyruntimestate;
|
2019-10-02 21:51:20 +00:00
|
|
|
struct _ceval_runtime_state;
|
2019-11-14 11:20:46 +00:00
|
|
|
|
2020-04-14 12:26:24 +00:00
|
|
|
#include "pycore_interp.h" /* PyInterpreterState.eval_frame */
|
2017-09-08 05:51:28 +00:00
|
|
|
|
2020-03-17 17:56:44 +00:00
|
|
|
extern void _Py_FinishPendingCalls(PyThreadState *tstate);
|
|
|
|
extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *);
|
2020-04-08 15:54:59 +00:00
|
|
|
extern int _PyEval_InitState(struct _ceval_state *ceval);
|
|
|
|
extern void _PyEval_FiniState(struct _ceval_state *ceval);
|
2020-04-08 21:35:05 +00:00
|
|
|
PyAPI_FUNC(void) _PyEval_SignalReceived(PyInterpreterState *interp);
|
2019-05-10 21:39:09 +00:00
|
|
|
PyAPI_FUNC(int) _PyEval_AddPendingCall(
|
2020-04-08 21:35:05 +00:00
|
|
|
PyInterpreterState *interp,
|
2019-05-10 21:39:09 +00:00
|
|
|
int (*func)(void *),
|
|
|
|
void *arg);
|
2021-02-19 14:10:45 +00:00
|
|
|
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *interp);
|
2020-04-14 16:16:24 +00:00
|
|
|
#ifdef HAVE_FORK
|
2020-06-02 16:44:54 +00:00
|
|
|
extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate);
|
2020-04-14 16:16:24 +00:00
|
|
|
#endif
|
2019-06-13 20:41:23 +00:00
|
|
|
PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(
|
|
|
|
PyThreadState *tstate,
|
|
|
|
int new_depth);
|
2017-09-08 05:51:28 +00:00
|
|
|
|
2019-06-03 12:30:58 +00:00
|
|
|
void _PyEval_Fini(void);
|
|
|
|
|
2021-02-18 18:20:16 +00:00
|
|
|
|
2021-02-20 14:17:18 +00:00
|
|
|
extern PyObject* _PyEval_GetBuiltins(PyThreadState *tstate);
|
|
|
|
extern PyObject *_PyEval_BuiltinsFromGlobals(
|
|
|
|
PyThreadState *tstate,
|
|
|
|
PyObject *globals);
|
2021-02-18 18:20:16 +00:00
|
|
|
|
|
|
|
|
2019-11-14 11:20:46 +00:00
|
|
|
static inline PyObject*
|
2020-04-28 14:32:48 +00:00
|
|
|
_PyEval_EvalFrame(PyThreadState *tstate, PyFrameObject *f, int throwflag)
|
2019-11-14 11:20:46 +00:00
|
|
|
{
|
2020-03-12 22:18:39 +00:00
|
|
|
return tstate->interp->eval_frame(tstate, f, throwflag);
|
2019-11-14 11:20:46 +00:00
|
|
|
}
|
|
|
|
|
2021-02-01 10:42:03 +00:00
|
|
|
extern PyObject *
|
|
|
|
_PyEval_Vector(PyThreadState *tstate,
|
|
|
|
PyFrameConstructor *desc, PyObject *locals,
|
|
|
|
PyObject* const* args, size_t argcount,
|
|
|
|
PyObject *kwnames);
|
2019-11-16 00:03:22 +00:00
|
|
|
|
2020-05-05 18:27:47 +00:00
|
|
|
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
|
|
|
extern int _PyEval_ThreadsInitialized(PyInterpreterState *interp);
|
|
|
|
#else
|
2020-04-14 12:26:24 +00:00
|
|
|
extern int _PyEval_ThreadsInitialized(struct pyruntimestate *runtime);
|
2020-05-05 18:27:47 +00:00
|
|
|
#endif
|
2020-04-08 15:54:59 +00:00
|
|
|
extern PyStatus _PyEval_InitGIL(PyThreadState *tstate);
|
2021-02-19 14:10:45 +00:00
|
|
|
extern void _PyEval_FiniGIL(PyInterpreterState *interp);
|
2020-03-09 20:24:14 +00:00
|
|
|
|
2020-03-18 01:26:04 +00:00
|
|
|
extern void _PyEval_ReleaseLock(PyThreadState *tstate);
|
|
|
|
|
2021-03-08 21:56:37 +00:00
|
|
|
extern void _PyEval_DeactivateOpCache(void);
|
|
|
|
|
2020-03-13 09:19:38 +00:00
|
|
|
|
|
|
|
/* --- _Py_EnterRecursiveCall() ----------------------------------------- */
|
|
|
|
|
|
|
|
#ifdef USE_STACKCHECK
|
|
|
|
/* With USE_STACKCHECK macro defined, trigger stack checks in
|
|
|
|
_Py_CheckRecursiveCall() on every 64th call to Py_EnterRecursiveCall. */
|
|
|
|
static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
|
2020-05-05 14:52:52 +00:00
|
|
|
return (++tstate->recursion_depth > tstate->interp->ceval.recursion_limit
|
2020-03-13 09:19:38 +00:00
|
|
|
|| ++tstate->stackcheck_counter > 64);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
|
2020-05-05 14:52:52 +00:00
|
|
|
return (++tstate->recursion_depth > tstate->interp->ceval.recursion_limit);
|
2020-03-13 09:19:38 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
PyAPI_FUNC(int) _Py_CheckRecursiveCall(
|
|
|
|
PyThreadState *tstate,
|
|
|
|
const char *where);
|
|
|
|
|
|
|
|
static inline int _Py_EnterRecursiveCall(PyThreadState *tstate,
|
|
|
|
const char *where) {
|
|
|
|
return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int _Py_EnterRecursiveCall_inline(const char *where) {
|
|
|
|
PyThreadState *tstate = PyThreadState_GET();
|
|
|
|
return _Py_EnterRecursiveCall(tstate, where);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define Py_EnterRecursiveCall(where) _Py_EnterRecursiveCall_inline(where)
|
|
|
|
|
|
|
|
static inline void _Py_LeaveRecursiveCall(PyThreadState *tstate) {
|
2020-05-05 14:52:52 +00:00
|
|
|
tstate->recursion_depth--;
|
2020-03-13 09:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void _Py_LeaveRecursiveCall_inline(void) {
|
|
|
|
PyThreadState *tstate = PyThreadState_GET();
|
|
|
|
_Py_LeaveRecursiveCall(tstate);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define Py_LeaveRecursiveCall() _Py_LeaveRecursiveCall_inline()
|
|
|
|
|
|
|
|
|
2017-09-08 05:51:28 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_INTERNAL_CEVAL_H */
|