[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: alloca patch

From: Paul Eggert
Subject: Re: alloca patch
Date: Fri, 21 Dec 2012 00:35:17 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 12/20/2012 07:31 AM, Eric Blake wrote:
I'm reluctant to patch this without also patching the
documentation to match

Me too.  I looked into it a bit, and pushed the following
which I hope fixes the problem for the BSDs.

From fd29dbd7d966f0fbde031a67955d77d50268c3d5 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Thu, 20 Dec 2012 21:21:04 -0800
Subject: [PATCH] AC_FUNC_ALLOCA: port to recent BSDs and remove obsolete AIX

* 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
As this adds stdlib.h, it should also fix the problems on recent
BSD platforms noted by Patrick Welche in
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         | 23 +++++------------------
 lib/autoconf/functions.m4 | 34 +++++++++++++++++-----------------
 2 files changed, 22 insertions(+), 35 deletions(-)

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 3f0dbb4..c9c1677 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -4858,15 +4858,11 @@ in some cases how they respond when given certain 
 @prindex @code{alloca}
 @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
address@hidden 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
address@hidden  Otherwise, it sets the output variable
address@hidden to @address@hidden@}alloca.o} and defines
+Check for the @code{alloca} function.  Define @code{HAVE_ALLOCA_H} if
address@hidden defines a working @code{alloca}.  If not, look for a
+builtin alternative.  If either method succeeds, define
address@hidden  Otherwise, set the output variable @code{ALLOCA} to
address@hidden@address@hidden 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 @address@hidden@}} 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
address@hidden 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
address@hidden 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
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index de7a6b8..db7be05 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -372,36 +372,36 @@ AC_CACHE_CHECK([for working alloca.h], 
 if test $ac_cv_working_alloca_h = yes; then
-           [Define to 1 if you have <alloca.h> and it should be used
-            (not on Ultrix).])
+           [Define to 1 if <alloca.h> works.])
AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
-[[#ifdef __GNUC__
-# define alloca __builtin_alloca
-# ifdef _MSC_VER
+[if test $ac_cv_working_alloca_h = yes; then
+  ac_cv_func_alloca_works=yes
+[[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
+# include <stdlib.h>
+#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
 ]],                               [[char *p = (char *) alloca (1);
                                    if (p) return 0;]])],
if test $ac_cv_func_alloca_works = yes; then

reply via email to

[Prev in Thread] Current Thread [Next in Thread]