Skip to content

Commit 7fec939

Browse files
encukoustefanor
authored andcommitted
Use autoconf for _Py_STACK_GROWS_DOWN
1 parent c0c9000 commit 7fec939

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

Include/internal/pycore_ceval.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ extern "C" {
1616
#include "pycore_stats.h" // EVAL_CALL_STAT_INC()
1717
#include "pycore_typedefs.h" // _PyInterpreterFrame
1818

19-
/* HP PA-RISC has a stack that goes up */
20-
#ifdef __hppa__
21-
# define _Py_STACK_GROWS_DOWN 0
22-
#else
23-
# define _Py_STACK_GROWS_DOWN 1
24-
#endif
2519

2620
/* Forward declarations */
2721
struct _ceval_runtime_state;

Include/pyport.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,4 +682,10 @@ extern "C" {
682682
#endif
683683

684684

685+
// Assume the stack grows down unless specified otherwise
686+
#ifndef _Py_STACK_GROWS_DOWN
687+
# define _Py_STACK_GROWS_DOWN 1
688+
#endif
689+
690+
685691
#endif /* Py_PYPORT_H */

configure

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,14 @@ if test x$MULTIARCH != x; then
12021202
fi
12031203
AC_SUBST([MULTIARCH_CPPFLAGS])
12041204

1205+
# Guess C stack direction
1206+
AS_CASE([$host],
1207+
[hppa-*], [_Py_STACK_GROWS_DOWN=0],
1208+
[_Py_STACK_GROWS_DOWN=1])
1209+
AC_DEFINE_UNQUOTED([_Py_STACK_GROWS_DOWN], [$_Py_STACK_GROWS_DOWN],
1210+
[Define to 1 if the machine stack grows down (default); 0 if it grows up.])
1211+
AC_SUBST([_Py_STACK_GROWS_DOWN])
1212+
12051213
dnl Support tiers according to https://peps.python.org/pep-0011/
12061214
dnl
12071215
dnl NOTE: Windows support tiers are defined in PC/pyconfig.h.

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,9 @@
20262026
/* HACL* library can compile SIMD256 implementations */
20272027
#undef _Py_HACL_CAN_COMPILE_VEC256
20282028

2029+
/* Define to 1 if the machine stack grows down (default); 0 if it grows up. */
2030+
#undef _Py_STACK_GROWS_DOWN
2031+
20292032
/* Define if you want to use tail-calling interpreters in CPython. */
20302033
#undef _Py_TAIL_CALL_INTERP
20312034

0 commit comments

Comments
 (0)