Obey tramp-histfile-override in remote direct async processes
[emacs.git] / m4 / alloca.m4
blobdc78dc19a8791aa73a1ea992e568281548d96467
1 # alloca.m4
2 # serial 21
3 dnl Copyright (C) 2002-2004, 2006-2007, 2009-2024 Free Software Foundation,
4 dnl Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 AC_DEFUN([gl_FUNC_ALLOCA],
11   AC_REQUIRE([AC_FUNC_ALLOCA])
12   if test $ac_cv_func_alloca_works = no; then
13     gl_PREREQ_ALLOCA
14   fi
16   # Define an additional variable used in the Makefile substitution.
17   if test $ac_cv_working_alloca_h = yes; then
18     AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [
19       AC_EGREP_CPP([Need own alloca], [
20 #if defined __GNUC__ || defined _AIX || defined _MSC_VER
21         Need own alloca
22 #endif
23         ], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no])
24     ])
25     if test $gl_cv_rpl_alloca = yes; then
26       dnl OK, alloca can be implemented through a compiler built-in.
27       AC_DEFINE([HAVE_ALLOCA], [1],
28         [Define to 1 if you have 'alloca' after including <alloca.h>,
29          a header that may be supplied by this distribution.])
30       GL_GENERATE_ALLOCA_H=true
31     else
32       dnl alloca exists as a library function, i.e. it is slow and probably
33       dnl a memory leak. Don't define HAVE_ALLOCA in this case.
34       GL_GENERATE_ALLOCA_H=false
35     fi
36   else
37     GL_GENERATE_ALLOCA_H=true
38   fi
40   if test $ac_cv_working_alloca_h = yes; then
41     HAVE_ALLOCA_H=1
42   else
43     HAVE_ALLOCA_H=0
44   fi
45   AC_SUBST([HAVE_ALLOCA_H])
48 # Prerequisites of lib/alloca.c.
49 # STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
50 AC_DEFUN([gl_PREREQ_ALLOCA], [:])
52 m4_version_prereq([2.70], [], [
54 # This works around a bug in autoconf <= 2.68 and has simplifications
55 # from 2.70.  See:
56 # https://lists.gnu.org/r/bug-gnulib/2011-06/msg00277.html
57 # https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497
58 # https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=15edf7fd8094fd14a89d9891dd72a9624762597a
60 # _AC_LIBOBJ_ALLOCA
61 # -----------------
62 # Set up the LIBOBJ replacement of 'alloca'.  Well, not exactly
63 # AC_LIBOBJ since we actually set the output variable 'ALLOCA'.
64 # Nevertheless, for Automake, AC_LIBSOURCES it.
65 m4_define([_AC_LIBOBJ_ALLOCA],
66 [# The SVR3 libPW and SVR4 libucb both contain incompatible functions
67 # that cause trouble.  Some versions do not even contain alloca or
68 # contain a buggy version.  If you still want to use their alloca,
69 # use ar to extract alloca.o from them instead of compiling alloca.c.
70 AC_LIBSOURCES(alloca.c)
71 AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
72 AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.])
74 AC_CACHE_CHECK([stack direction for C alloca],
75                [ac_cv_c_stack_direction],
76 [AC_RUN_IFELSE([AC_LANG_SOURCE(
77 [AC_INCLUDES_DEFAULT
78 int
79 find_stack_direction (int *addr, int depth)
81   int dir, dummy = 0;
82   if (! addr)
83     addr = &dummy;
84   *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
85   dir = depth ? find_stack_direction (addr, depth - 1) : 0;
86   return dir + dummy;
89 int
90 main (int argc, char **argv)
92   return find_stack_direction (0, argc + !argv + 20) < 0;
93 }])],
94                [ac_cv_c_stack_direction=1],
95                [ac_cv_c_stack_direction=-1],
96                [ac_cv_c_stack_direction=0])])
97 AH_VERBATIM([STACK_DIRECTION],
98 [/* If using the C implementation of alloca, define if you know the
99    direction of stack growth for your system; otherwise it will be
100    automatically deduced at runtime.
101         STACK_DIRECTION > 0 => grows toward higher addresses
102         STACK_DIRECTION < 0 => grows toward lower addresses
103         STACK_DIRECTION = 0 => direction of growth unknown */
104 #undef STACK_DIRECTION])dnl
105 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
106 ])# _AC_LIBOBJ_ALLOCA