Skip to content

Commit b217e3f

Browse files
committed
Found another stack computation
1 parent 4434b24 commit b217e3f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Include/internal/pycore_pystate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,11 @@ _Py_RecursionLimit_GetMargin(PyThreadState *tstate)
326326
_PyThreadStateImpl *_tstate = (_PyThreadStateImpl *)tstate;
327327
assert(_tstate->c_stack_hard_limit != 0);
328328
intptr_t here_addr = _Py_get_machine_stack_pointer();
329+
#if _Py_STACK_GROWS_DOWN
329330
return Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, here_addr - (intptr_t)_tstate->c_stack_soft_limit, _PyOS_STACK_MARGIN_SHIFT);
331+
#else
332+
return Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, (intptr_t)_tstate->c_stack_soft_limit - here_addr, _PyOS_STACK_MARGIN_SHIFT);
333+
#endif
330334
}
331335

332336
#ifdef __cplusplus

0 commit comments

Comments
 (0)