2021-04-17 06:14:21 -04:00
|
|
|
dnl -*- Autoconf -*-
|
2018-01-20 02:05:25 -05:00
|
|
|
AC_DEFUN([RUBY_STACK_GROW_DIRECTION], [
|
|
|
|
AS_VAR_PUSHDEF([stack_grow_dir], [rb_cv_stack_grow_dir_$1])
|
|
|
|
AC_CACHE_CHECK(stack growing direction on $1, stack_grow_dir, [
|
|
|
|
AS_CASE(["$1"],
|
2019-06-19 05:06:57 -04:00
|
|
|
[m68*|x86*|x64|i?86|ppc*|sparc*|alpha*], [ $2=-1],
|
2018-01-20 02:05:25 -05:00
|
|
|
[hppa*], [ $2=+1],
|
|
|
|
[
|
2020-12-12 08:55:09 -05:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
2018-01-20 02:05:25 -05:00
|
|
|
/* recurse to get rid of inlining */
|
|
|
|
static int
|
|
|
|
stack_growup_p(addr, n)
|
|
|
|
volatile int *addr, n;
|
|
|
|
{
|
|
|
|
volatile int end;
|
|
|
|
if (n > 0)
|
|
|
|
return *addr = stack_growup_p(addr, n - 1);
|
|
|
|
else
|
|
|
|
return (&end > addr);
|
|
|
|
}
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
return stack_growup_p(&x, 10);
|
|
|
|
}
|
2020-12-12 08:55:09 -05:00
|
|
|
]])],[$2=-1],[$2=+1],[$2=0])
|
2018-01-20 02:05:25 -05:00
|
|
|
])
|
|
|
|
eval stack_grow_dir=\$$2])
|
|
|
|
eval $2=\$stack_grow_dir
|
|
|
|
AS_VAR_POPDEF([stack_grow_dir])])dnl
|