summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_ceval.h
diff options
context:
space:
mode:
Diffstat (limited to 'Include/internal/pycore_ceval.h')
-rw-r--r--Include/internal/pycore_ceval.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index 6eab2ba..946f82a 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -138,12 +138,12 @@ extern void _PyEval_DeactivateOpCache(void);
/* 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->c_recursion_remaining-- <= 0
+ return (tstate->c_recursion_remaining-- < 0
|| (tstate->c_recursion_remaining & 63) == 0);
}
#else
static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
- return tstate->c_recursion_remaining-- <= 0;
+ return tstate->c_recursion_remaining-- < 0;
}
#endif
@@ -161,6 +161,11 @@ static inline int _Py_EnterRecursiveCallTstate(PyThreadState *tstate,
return (_Py_MakeRecCheck(tstate) && _Py_CheckRecursiveCall(tstate, where));
}
+static inline void _Py_EnterRecursiveCallTstateUnchecked(PyThreadState *tstate) {
+ assert(tstate->c_recursion_remaining > 0);
+ tstate->c_recursion_remaining--;
+}
+
static inline int _Py_EnterRecursiveCall(const char *where) {
PyThreadState *tstate = _PyThreadState_GET();
return _Py_EnterRecursiveCallTstate(tstate, where);