2017-09-08 02:51:28 -03:00
|
|
|
#ifndef Py_INTERNAL_CEVAL_H
|
|
|
|
#define Py_INTERNAL_CEVAL_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-04-17 18:02:26 -03:00
|
|
|
#ifndef Py_BUILD_CORE
|
|
|
|
# error "this header requires Py_BUILD_CORE define"
|
2018-11-09 08:03:37 -04:00
|
|
|
#endif
|
|
|
|
|
2019-10-02 18:51:20 -03:00
|
|
|
/* Forward declarations */
|
2019-10-03 21:21:05 -03:00
|
|
|
struct pyruntimestate;
|
2019-10-02 18:51:20 -03:00
|
|
|
struct _ceval_runtime_state;
|
2019-11-14 07:20:46 -04:00
|
|
|
struct _frame;
|
|
|
|
|
2020-04-14 09:26:24 -03:00
|
|
|
#include "pycore_interp.h" /* PyInterpreterState.eval_frame */
|
2017-09-08 02:51:28 -03:00
|
|
|
|
2020-03-17 14:56:44 -03:00
|
|
|
extern void _Py_FinishPendingCalls(PyThreadState *tstate);
|
|
|
|
extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *);
|
2020-04-08 12:54:59 -03:00
|
|
|
extern int _PyEval_InitState(struct _ceval_state *ceval);
|
|
|
|
extern void _PyEval_FiniState(struct _ceval_state *ceval);
|
2020-04-08 18:35:05 -03:00
|
|
|
PyAPI_FUNC(void) _PyEval_SignalReceived(PyInterpreterState *interp);
|
2019-05-10 18:39:09 -03:00
|
|
|
PyAPI_FUNC(int) _PyEval_AddPendingCall(
|
2020-04-08 18:35:05 -03:00
|
|
|
PyInterpreterState *interp,
|
2019-05-10 18:39:09 -03:00
|
|
|
int (*func)(void *),
|
|
|
|
void *arg);
|
2020-03-18 05:26:25 -03:00
|
|
|
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyThreadState *tstate);
|
2019-05-13 07:35:37 -03:00
|
|
|
PyAPI_FUNC(void) _PyEval_ReInitThreads(
|
2019-10-03 21:21:05 -03:00
|
|
|
struct pyruntimestate *runtime);
|
2019-06-13 17:41:23 -03:00
|
|
|
PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(
|
|
|
|
PyThreadState *tstate,
|
|
|
|
int new_depth);
|
2017-09-08 02:51:28 -03:00
|
|
|
|
2019-06-03 09:30:58 -03:00
|
|
|
/* Private function */
|
|
|
|
void _PyEval_Fini(void);
|
|
|
|
|
2019-11-14 07:20:46 -04:00
|
|
|
static inline PyObject*
|
|
|
|
_PyEval_EvalFrame(PyThreadState *tstate, struct _frame *f, int throwflag)
|
|
|
|
{
|
2020-03-12 19:18:39 -03:00
|
|
|
return tstate->interp->eval_frame(tstate, f, throwflag);
|
2019-11-14 07:20:46 -04:00
|
|
|
}
|
|
|
|
|
2019-11-15 20:03:22 -04:00
|
|
|
extern PyObject *_PyEval_EvalCode(
|
|
|
|
PyThreadState *tstate,
|
|
|
|
PyObject *_co, PyObject *globals, PyObject *locals,
|
|
|
|
PyObject *const *args, Py_ssize_t argcount,
|
|
|
|
PyObject *const *kwnames, PyObject *const *kwargs,
|
|
|
|
Py_ssize_t kwcount, int kwstep,
|
|
|
|
PyObject *const *defs, Py_ssize_t defcount,
|
|
|
|
PyObject *kwdefs, PyObject *closure,
|
|
|
|
PyObject *name, PyObject *qualname);
|
|
|
|
|
2020-04-14 09:26:24 -03:00
|
|
|
extern int _PyEval_ThreadsInitialized(struct pyruntimestate *runtime);
|
2020-04-08 12:54:59 -03:00
|
|
|
extern PyStatus _PyEval_InitGIL(PyThreadState *tstate);
|
|
|
|
extern void _PyEval_FiniGIL(PyThreadState *tstate);
|
2020-03-09 17:24:14 -03:00
|
|
|
|
2020-03-17 22:26:04 -03:00
|
|
|
extern void _PyEval_ReleaseLock(PyThreadState *tstate);
|
|
|
|
|
2020-03-13 06:19:38 -03:00
|
|
|
|
|
|
|
/* --- _Py_EnterRecursiveCall() ----------------------------------------- */
|
|
|
|
|
|
|
|
PyAPI_DATA(int) _Py_CheckRecursionLimit;
|
|
|
|
|
|
|
|
#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) {
|
|
|
|
return (++tstate->recursion_depth > _Py_CheckRecursionLimit
|
|
|
|
|| ++tstate->stackcheck_counter > 64);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
|
|
|
|
return (++tstate->recursion_depth > _Py_CheckRecursionLimit);
|
|
|
|
}
|
|
|
|
#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)
|
|
|
|
|
|
|
|
|
|
|
|
/* Compute the "lower-water mark" for a recursion limit. When
|
|
|
|
* Py_LeaveRecursiveCall() is called with a recursion depth below this mark,
|
|
|
|
* the overflowed flag is reset to 0. */
|
|
|
|
#define _Py_RecursionLimitLowerWaterMark(limit) \
|
|
|
|
(((limit) > 200) \
|
|
|
|
? ((limit) - 50) \
|
|
|
|
: (3 * ((limit) >> 2)))
|
|
|
|
|
|
|
|
#define _Py_MakeEndRecCheck(x) \
|
|
|
|
(--(x) < _Py_RecursionLimitLowerWaterMark(_Py_CheckRecursionLimit))
|
|
|
|
|
|
|
|
static inline void _Py_LeaveRecursiveCall(PyThreadState *tstate) {
|
|
|
|
if (_Py_MakeEndRecCheck(tstate->recursion_depth)) {
|
|
|
|
tstate->overflowed = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void _Py_LeaveRecursiveCall_inline(void) {
|
|
|
|
PyThreadState *tstate = PyThreadState_GET();
|
|
|
|
_Py_LeaveRecursiveCall(tstate);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define Py_LeaveRecursiveCall() _Py_LeaveRecursiveCall_inline()
|
|
|
|
|
|
|
|
|
2017-09-08 02:51:28 -03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_INTERNAL_CEVAL_H */
|