2012-05-26 23:14:36 +00:00
|
|
|
# alloca.m4 serial 14
|
2018-01-01 01:19:57 +00:00
|
|
|
dnl Copyright (C) 2002-2004, 2006-2007, 2009-2018 Free Software Foundation,
|
2017-01-01 09:32:27 +00:00
|
|
|
dnl Inc.
|
2011-06-21 16:15:07 +00:00
|
|
|
dnl This file is free software; the Free Software Foundation
|
|
|
|
dnl gives unlimited permission to copy and/or distribute it,
|
|
|
|
dnl with or without modifications, as long as this notice is preserved.
|
|
|
|
|
|
|
|
AC_DEFUN([gl_FUNC_ALLOCA],
|
|
|
|
[
|
|
|
|
AC_REQUIRE([AC_FUNC_ALLOCA])
|
|
|
|
if test $ac_cv_func_alloca_works = no; then
|
|
|
|
gl_PREREQ_ALLOCA
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Define an additional variable used in the Makefile substitution.
|
|
|
|
if test $ac_cv_working_alloca_h = yes; then
|
|
|
|
AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [
|
|
|
|
AC_EGREP_CPP([Need own alloca], [
|
|
|
|
#if defined __GNUC__ || defined _AIX || defined _MSC_VER
|
|
|
|
Need own alloca
|
|
|
|
#endif
|
|
|
|
], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no])
|
|
|
|
])
|
|
|
|
if test $gl_cv_rpl_alloca = yes; then
|
|
|
|
dnl OK, alloca can be implemented through a compiler built-in.
|
|
|
|
AC_DEFINE([HAVE_ALLOCA], [1],
|
|
|
|
[Define to 1 if you have 'alloca' after including <alloca.h>,
|
|
|
|
a header that may be supplied by this distribution.])
|
|
|
|
ALLOCA_H=alloca.h
|
|
|
|
else
|
|
|
|
dnl alloca exists as a library function, i.e. it is slow and probably
|
|
|
|
dnl a memory leak. Don't define HAVE_ALLOCA in this case.
|
|
|
|
ALLOCA_H=
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
ALLOCA_H=alloca.h
|
|
|
|
fi
|
|
|
|
AC_SUBST([ALLOCA_H])
|
|
|
|
AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"])
|
|
|
|
])
|
|
|
|
|
|
|
|
# Prerequisites of lib/alloca.c.
|
|
|
|
# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
|
|
|
|
AC_DEFUN([gl_PREREQ_ALLOCA], [:])
|
|
|
|
|
|
|
|
# This works around a bug in autoconf <= 2.68.
|
Merge from Gnulib
This incorporates:
2017-11-23 stat: work around Solaris bug with tv_nsec < 0
2017-11-12 maint: shorten https://lists.gnu.org/archive/html/... links
* build-aux/config.sub, doc/misc/texinfo.tex, lib/allocator.h:
* lib/fstatat.c, lib/intprops.h, lib/lstat.c, lib/signal.in.h:
* lib/stat-time.h, lib/stdio-impl.h, lib/stdio.in.h:
* lib/timespec.h, m4/alloca.m4, m4/extern-inline.m4:
* m4/faccessat.m4, m4/fstatat.m4, m4/gnulib-common.m4:
* m4/lstat.m4, m4/std-gnu11.m4, m4/sys_types_h.m4:
* m4/vararrays.m4:
Copy from Gnulib.
2017-11-26 06:28:31 +00:00
|
|
|
# See <https://lists.gnu.org/r/bug-gnulib/2011-06/msg00277.html>.
|
2011-06-21 16:15:07 +00:00
|
|
|
|
|
|
|
m4_version_prereq([2.69], [] ,[
|
|
|
|
|
|
|
|
# This is taken from the following Autoconf patch:
|
Merge from Gnulib
This incorporates:
2017-09-16 manywarnings: port to GCC on 64-bit MS-Windows
2017-09-13 all: Replace many more http URLs by https URLs
* build-aux/config.guess, build-aux/config.sub:
* build-aux/gitlog-to-changelog, doc/misc/texinfo.tex:
* lib/allocator.h, lib/count-leading-zeros.h:
* lib/count-trailing-zeros.h, lib/dup2.c, lib/filevercmp.c:
* lib/fstatat.c, lib/fsync.c, lib/ftoastr.c, lib/ftoastr.h:
* lib/intprops.h, lib/signal.in.h, lib/stdio-impl.h, lib/stdio.in.h:
* lib/unistd.in.h, lib/utimens.c, m4/alloca.m4, m4/extern-inline.m4:
* m4/fstatat.m4, m4/gnulib-common.m4, m4/manywarnings.m4:
* m4/std-gnu11.m4, m4/sys_types_h.m4, m4/vararrays.m4:
Copy from Gnulib.
* lib/gnulib.mk.in: Regenerate.
2017-09-17 19:56:00 +00:00
|
|
|
# https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=6cd9f12520b0d6f76d3230d7565feba1ecf29497
|
2011-06-21 16:15:07 +00:00
|
|
|
|
|
|
|
# _AC_LIBOBJ_ALLOCA
|
|
|
|
# -----------------
|
2012-05-26 23:14:36 +00:00
|
|
|
# Set up the LIBOBJ replacement of 'alloca'. Well, not exactly
|
|
|
|
# AC_LIBOBJ since we actually set the output variable 'ALLOCA'.
|
2011-06-21 16:15:07 +00:00
|
|
|
# Nevertheless, for Automake, AC_LIBSOURCES it.
|
|
|
|
m4_define([_AC_LIBOBJ_ALLOCA],
|
|
|
|
[# The SVR3 libPW and SVR4 libucb both contain incompatible functions
|
|
|
|
# that cause trouble. Some versions do not even contain alloca or
|
|
|
|
# contain a buggy version. If you still want to use their alloca,
|
|
|
|
# use ar to extract alloca.o from them instead of compiling alloca.c.
|
|
|
|
AC_LIBSOURCES(alloca.c)
|
|
|
|
AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
|
2012-05-26 23:14:36 +00:00
|
|
|
AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.])
|
2011-06-21 16:15:07 +00:00
|
|
|
|
2012-05-26 23:14:36 +00:00
|
|
|
AC_CACHE_CHECK(whether 'alloca.c' needs Cray hooks, ac_cv_os_cray,
|
2011-06-21 16:15:07 +00:00
|
|
|
[AC_EGREP_CPP(webecray,
|
|
|
|
[#if defined CRAY && ! defined CRAY2
|
|
|
|
webecray
|
|
|
|
#else
|
|
|
|
wenotbecray
|
|
|
|
#endif
|
|
|
|
], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
|
|
|
|
if test $ac_cv_os_cray = yes; then
|
|
|
|
for ac_func in _getb67 GETB67 getb67; do
|
|
|
|
AC_CHECK_FUNC($ac_func,
|
2011-07-06 16:19:38 +00:00
|
|
|
[AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
|
2012-05-26 23:14:36 +00:00
|
|
|
[Define to one of '_getb67', 'GETB67',
|
|
|
|
'getb67' for Cray-2 and Cray-YMP
|
2011-07-06 16:19:38 +00:00
|
|
|
systems. This function is required for
|
2012-05-26 23:14:36 +00:00
|
|
|
'alloca.c' support on those systems.])
|
2011-06-21 16:15:07 +00:00
|
|
|
break])
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
AC_CACHE_CHECK([stack direction for C alloca],
|
2011-07-06 16:19:38 +00:00
|
|
|
[ac_cv_c_stack_direction],
|
2011-06-21 16:15:07 +00:00
|
|
|
[AC_RUN_IFELSE([AC_LANG_SOURCE(
|
|
|
|
[AC_INCLUDES_DEFAULT
|
|
|
|
int
|
|
|
|
find_stack_direction (int *addr, int depth)
|
|
|
|
{
|
|
|
|
int dir, dummy = 0;
|
|
|
|
if (! addr)
|
|
|
|
addr = &dummy;
|
|
|
|
*addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
|
|
|
|
dir = depth ? find_stack_direction (addr, depth - 1) : 0;
|
|
|
|
return dir + dummy;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
return find_stack_direction (0, argc + !argv + 20) < 0;
|
|
|
|
}])],
|
2011-07-06 16:19:38 +00:00
|
|
|
[ac_cv_c_stack_direction=1],
|
|
|
|
[ac_cv_c_stack_direction=-1],
|
|
|
|
[ac_cv_c_stack_direction=0])])
|
2011-06-21 16:15:07 +00:00
|
|
|
AH_VERBATIM([STACK_DIRECTION],
|
|
|
|
[/* If using the C implementation of alloca, define if you know the
|
|
|
|
direction of stack growth for your system; otherwise it will be
|
|
|
|
automatically deduced at runtime.
|
2011-07-06 16:19:38 +00:00
|
|
|
STACK_DIRECTION > 0 => grows toward higher addresses
|
|
|
|
STACK_DIRECTION < 0 => grows toward lower addresses
|
|
|
|
STACK_DIRECTION = 0 => direction of growth unknown */
|
2011-06-21 16:15:07 +00:00
|
|
|
@%:@undef STACK_DIRECTION])dnl
|
|
|
|
AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
|
|
|
|
])# _AC_LIBOBJ_ALLOCA
|
|
|
|
])
|