2021-12-19 00:12:38 +00:00
|
|
|
# alloca.m4 serial 21
|
2023-01-07 01:53:54 +00:00
|
|
|
dnl Copyright (C) 2002-2004, 2006-2007, 2009-2023 Free Software Foundation,
|
|
|
|
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.])
|
2021-12-19 00:12:38 +00:00
|
|
|
GL_GENERATE_ALLOCA_H=true
|
2011-06-21 16:15:07 +00:00
|
|
|
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.
|
2021-12-19 00:12:38 +00:00
|
|
|
GL_GENERATE_ALLOCA_H=false
|
2011-06-21 16:15:07 +00:00
|
|
|
fi
|
|
|
|
else
|
2021-12-19 00:12:38 +00:00
|
|
|
GL_GENERATE_ALLOCA_H=true
|
2011-06-21 16:15:07 +00:00
|
|
|
fi
|
2019-03-11 06:03:48 +00:00
|
|
|
|
|
|
|
if test $ac_cv_working_alloca_h = yes; then
|
|
|
|
HAVE_ALLOCA_H=1
|
|
|
|
else
|
|
|
|
HAVE_ALLOCA_H=0
|
|
|
|
fi
|
|
|
|
AC_SUBST([HAVE_ALLOCA_H])
|
2011-06-21 16:15:07 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
# Prerequisites of lib/alloca.c.
|
|
|
|
# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
|
|
|
|
AC_DEFUN([gl_PREREQ_ALLOCA], [:])
|
|
|
|
|
Update from Gnulib
This incorporates:
2020-08-06 libgmp: add <gmp/gmp.h> support
2020-08-06 Consider that clang defines __OPTIMIZE__ like GCC does
2020-08-06 Use __builtin_expect with clang everywhere
2020-08-05 Use __builtin_clz{,l,ll} with clang, also on Windows
2020-08-05 Use __builtin_ctz{,l,ll} and __builtin_ffs{,l,ll} with clang
2020-07-31 _GL_CMP: Improve documentation
2020-07-30 alloca, largefile: sync with Autoconf master
* lib/c++defs.h, lib/cdefs.h, lib/count-leading-zeros.h:
* lib/count-trailing-zeros.h, m4/alloca.m4, m4/gnulib-common.m4:
* m4/largefile.m4, m4/libgmp.m4:
Copy from Gnulib.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
2020-08-06 22:24:47 +00:00
|
|
|
m4_version_prereq([2.70], [], [
|
|
|
|
|
|
|
|
# This works around a bug in autoconf <= 2.68 and has simplifications
|
|
|
|
# from 2.70. See:
|
|
|
|
# https://lists.gnu.org/r/bug-gnulib/2011-06/msg00277.html
|
|
|
|
# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497
|
|
|
|
# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=15edf7fd8094fd14a89d9891dd72a9624762597a
|
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
|
|
|
|
|
|
|
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 */
|
Update from Gnulib
This incorporates:
2020-08-16 time_rz: remove unused functions
2020-08-16 time_rz: fix issues with mktime_z failures
2020-08-16 nstrftime: Guide inlining also on clang
2020-08-16 intprops: Avoid bogus warning on clang
2020-08-16 libc-config: Enable __REDIRECT macro also on clang
2020-08-16 regex: Use initializer shorthand syntax also with clang
2020-08-16 regex: Use space optimization also with clang
2020-08-16 Use _Static_assert and static_assert when present on clang
2020-08-16 Use 'throw ()' for optimization in C++ mode also on clang
2020-08-16 stdio: Don't break attribute 'scanf' on clang
2020-08-16 Fix "warning: 'format' attribute ...: rpl_printf"
2020-08-16 Fix "warning: attribute declaration must precede definition"
2020-08-16 Fix undesired warnings
2020-08-16 Don't use Autoconf quadrigraphsxo
2020-08-16 Fix quoting of AC_LANG_PROGRAM arguments
2020-08-16 Assume autoconf >= 2.64
2020-08-15 nstrftime: be more predictable about errno
2020-08-15 canonicalize: Fix autoconf test on MSVC/clang
2020-08-15 Support compiling without -loldnames on native Windows
2020-08-14 mktime, mktime-internal: Remove obsolete code
2020-08-14 Assume tzset exists
* lib/c++defs.h, lib/canonicalize-lgpl.c, lib/cdefs.h, lib/dup2.c:
* lib/fcntl.in.h, lib/getopt-cdefs.in.h, lib/intprops.h, lib/md5.h:
* lib/mktime.c, lib/nstrftime.c, lib/open.c, lib/regcomp.c:
* lib/regex_internal.h, lib/stdio.in.h, lib/stdlib.in.h:
* lib/strftime.h, lib/string.in.h, lib/sys_select.in.h:
* lib/sys_stat.in.h, lib/sys_time.in.h, lib/time.in.h, lib/time_rz.c:
* lib/unistd.in.h, lib/verify.h, m4/00gnulib.m4:
* m4/absolute-header.m4, m4/alloca.m4, m4/canonicalize.m4, m4/dup2.m4:
* m4/fchmodat.m4, m4/fcntl.m4, m4/fdopendir.m4, m4/fpending.m4:
* m4/futimens.m4, m4/getdtablesize.m4, m4/getloadavg.m4:
* m4/gnulib-common.m4, m4/include_next.m4, m4/largefile.m4:
* m4/manywarnings.m4, m4/mktime.m4, m4/nstrftime.m4, m4/open-slash.m4:
* m4/pselect.m4, m4/pthread_sigmask.m4, m4/time_h.m4, m4/utimens.m4:
* m4/utimensat.m4, m4/utimes.m4, m4/warnings.m4:
Copy from Gnulib.
* lib/gnulib.mk.in: Regenerate.
2020-08-16 21:22:56 +00:00
|
|
|
#undef STACK_DIRECTION])dnl
|
2011-06-21 16:15:07 +00:00
|
|
|
AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
|
2020-12-24 15:48:40 +00:00
|
|
|
])# _AC_LIBOBJ_ALLOCA
|
Update from Gnulib
This incorporates:
2020-08-06 libgmp: add <gmp/gmp.h> support
2020-08-06 Consider that clang defines __OPTIMIZE__ like GCC does
2020-08-06 Use __builtin_expect with clang everywhere
2020-08-05 Use __builtin_clz{,l,ll} with clang, also on Windows
2020-08-05 Use __builtin_ctz{,l,ll} and __builtin_ffs{,l,ll} with clang
2020-07-31 _GL_CMP: Improve documentation
2020-07-30 alloca, largefile: sync with Autoconf master
* lib/c++defs.h, lib/cdefs.h, lib/count-leading-zeros.h:
* lib/count-trailing-zeros.h, m4/alloca.m4, m4/gnulib-common.m4:
* m4/largefile.m4, m4/libgmp.m4:
Copy from Gnulib.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
2020-08-06 22:24:47 +00:00
|
|
|
])
|