]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
AC_FUNC_ALLOCA: port to recent BSDs and remove obsolete AIX
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 21 Dec 2012 05:21:04 +0000 (21:21 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 21 Dec 2012 05:22:34 +0000 (21:22 -0800)
* doc/autoconf.texi (Particular Functions): Remove the AIX case
from the recommended code, as the most recent version of the AIX
compiler that IBM still supports (V10.1 as of this writing) has
<alloca.h> and thus longer needs this, and the old suggestion
wasn't completely working anyway.  Remove obsolete discussion of
SVR3 libPW alloca and of SVR4 libucb alloca.
* lib/autoconf/functions.m4 (AC_FUNC_ALLOCA):
Rework to match documentation, including abovementioned AIX change.
Inconsistency with documentation reported by Steven G. Johnson in
<http://lists.gnu.org/archive/html/autoconf/2003-03/msg00179.html>.
As this adds stdlib.h, it should also fix the problems on recent
BSD platforms noted by Patrick Welche in
http://lists.gnu.org/archive/html/autoconf-patches/2012-12/msg00009.html
though the fix differs from NetBSD's current workaround.
Also, don't bother checking for alloca if <alloca.h> works,
as the latter implies the former.

doc/autoconf.texi
lib/autoconf/functions.m4

index 3f0dbb413d915bff62975741f50770b908d77f94..c9c1677d8a2616895b443dc6c0a1ca34f7e063ee 100644 (file)
@@ -4858,15 +4858,11 @@ in some cases how they respond when given certain arguments.
 @prindex @code{alloca}
 @hdrindex{alloca.h}
 @c @caindex working_alloca_h
-Check how to get @code{alloca}.  Tries to get a builtin version by
-checking for @file{alloca.h} or the predefined C preprocessor macros
-@code{__GNUC__} and @code{_AIX}.  If this macro finds @file{alloca.h},
-it defines @code{HAVE_ALLOCA_H}.
-
-If those attempts fail, it looks for the function in the standard C
-library.  If any of those methods succeed, it defines
-@code{HAVE_ALLOCA}.  Otherwise, it sets the output variable
-@code{ALLOCA} to @samp{$@{LIBOBJDIR@}alloca.o} and defines
+Check for the @code{alloca} function.  Define @code{HAVE_ALLOCA_H} if
+@file{alloca.h} defines a working @code{alloca}.  If not, look for a
+builtin alternative.  If either method succeeds, define
+@code{HAVE_ALLOCA}.  Otherwise, set the output variable @code{ALLOCA} to
+@samp{$@{LIBOBJDIR@}alloca.o} and define
 @code{C_ALLOCA} (so programs can periodically call @samp{alloca (0)} to
 garbage collect).  This variable is separate from @code{LIBOBJS} so
 multiple programs can share the value of @code{ALLOCA} without needing
@@ -4874,13 +4870,6 @@ to create an actual library, in case only some of them use the code in
 @code{LIBOBJS}.  The @samp{$@{LIBOBJDIR@}} prefix serves the same
 purpose as in @code{LIBOBJS} (@pxref{AC_LIBOBJ vs LIBOBJS}).
 
-This macro does not try to get @code{alloca} from the System V R3
-@file{libPW} or the System V R4 @file{libucb} because those libraries
-contain some incompatible functions that cause trouble.  Some versions
-do not even contain @code{alloca} or contain a buggy version.  If you
-still want to use their @code{alloca}, use @code{ar} to extract
-@file{alloca.o} from them instead of compiling @file{alloca.c}.
-
 Source files that use @code{alloca} should start with a piece of code
 like the following, to declare it properly.
 
@@ -4895,8 +4884,6 @@ like the following, to declare it properly.
 #elif !defined alloca
 # ifdef __GNUC__
 #  define alloca __builtin_alloca
-# elif defined _AIX
-#  define alloca __alloca
 # elif defined _MSC_VER
 #  include <malloc.h>
 #  define alloca _alloca
index de7a6b860ea87c85e149c259450f72c0bd40b619..db7be05268991ec46a66d8d13b14b19357a9a8e9 100644 (file)
@@ -372,36 +372,36 @@ AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h,
                [ac_cv_working_alloca_h=no])])
 if test $ac_cv_working_alloca_h = yes; then
   AC_DEFINE(HAVE_ALLOCA_H, 1,
-           [Define to 1 if you have <alloca.h> and it should be used
-            (not on Ultrix).])
+           [Define to 1 if <alloca.h> works.])
 fi
 
 AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[#ifdef __GNUC__
-# define alloca __builtin_alloca
-#else
-# ifdef _MSC_VER
+[if test $ac_cv_working_alloca_h = yes; then
+  ac_cv_func_alloca_works=yes
+else
+  AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+#include <stddef.h>
+#ifndef alloca
+# ifdef __GNUC__
+#  define alloca __builtin_alloca
+# elif defined _MSC_VER
 #  include <malloc.h>
 #  define alloca _alloca
 # else
-#  ifdef HAVE_ALLOCA_H
-#   include <alloca.h>
-#  else
-#   ifdef _AIX
- #pragma alloca
-#   else
-#    ifndef alloca /* predefined by HP cc +Olibcalls */
-void *alloca (size_t);
-#    endif
-#   endif
+#  ifdef  __cplusplus
+extern "C"
 #  endif
+void *alloca (size_t);
 # endif
 #endif
 ]],                               [[char *p = (char *) alloca (1);
                                    if (p) return 0;]])],
                [ac_cv_func_alloca_works=yes],
                [ac_cv_func_alloca_works=no])])
+fi
 
 if test $ac_cv_func_alloca_works = yes; then
   AC_DEFINE(HAVE_ALLOCA, 1,