1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-03 02:36:19 +02:00

Improve stack direction test

* configure.in: Update stack direction test to be like that in
	Autoconf _AC_LIBOBJ_ALLOCA and Gnulib; specifically in involving a
	function calling itself.
This commit is contained in:
Neil Jerram 2008-07-11 23:30:19 +01:00
parent 4ff3575c77
commit 9143131b27
2 changed files with 36 additions and 6 deletions

1
NEWS
View file

@ -20,6 +20,7 @@ application code.
** `guile-config link' now prints `-L$libdir' before `-lguile'
** Fix build issue on Tru64 and ia64-hp-hpux11.23 (`SCM_UNPACK' macro)
** Fix build issue on mips, mipsel, powerpc and ia64 (stack direction)
Changes in 1.8.5 (since 1.8.4)

View file

@ -1118,15 +1118,44 @@ GUILE_STRUCT_UTIMBUF
#
# Which way does the stack grow?
#
# Following code comes from Autoconf 2.61's internal _AC_LIBOBJ_ALLOCA
# macro (/usr/share/autoconf/autoconf/functions.m4). Gnulib has
# very similar code, so in future we could look at using that.
#
# An important detail is that the code involves find_stack_direction
# calling _itself_ - which means that find_stack_direction (or at
# least the second find_stack_direction() call) cannot be inlined.
# If the code could be inlined, that might cause the test to give
# an incorrect answer.
#--------------------------------------------------------------------
SCM_I_GSC_STACK_GROWS_UP=0
AC_RUN_IFELSE([AC_LANG_SOURCE([[aux (l) unsigned long l;
{ int x; exit (l >= ((unsigned long)&x)); }
main () { int q; aux((unsigned long)&q); }]])],
[SCM_I_GSC_STACK_GROWS_UP=1],
[],
[AC_MSG_WARN(Guessing that stack grows down -- see scmconfig.h)])
AC_CACHE_CHECK([stack direction],
[SCM_I_GSC_STACK_GROWS_UP],
[AC_RUN_IFELSE([AC_LANG_SOURCE(
[AC_INCLUDES_DEFAULT
int
find_stack_direction ()
{
static char *addr = 0;
auto char dummy;
if (addr == 0)
{
addr = &dummy;
return find_stack_direction ();
}
else
return (&dummy > addr) ? 1 : -1;
}
int
main ()
{
return find_stack_direction () < 0;
}])],
[SCM_I_GSC_STACK_GROWS_UP=1],
[],
[AC_MSG_WARN(Guessing that stack grows down -- see scmconfig.h)])])
AC_CHECK_SIZEOF(float)
if test "$ac_cv_sizeof_float" -le "$ac_cv_sizeof_long"; then