[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] docs: update alloca recommendations
From: |
Giorgos Keramidas |
Subject: |
Re: [PATCH] docs: update alloca recommendations |
Date: |
Wed, 08 Sep 2010 18:36:06 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) |
This looks excellent! Thanks.
Once it hits the autoconf source tree, we can update the GNU Emacs
configure.in script too.
On Wed, 8 Sep 2010 09:32:52 -0600, Eric Blake <address@hidden> wrote:
> * doc/autoconf.texi (Particular Functions): Don't redeclare alloca
> on FreeBSD.
> * THANKS: Update.
> Reported by Giorgos Keramidas.
>
> Signed-off-by: Eric Blake <address@hidden>
> ---
>
>>> #elif !defined(HAVE_ALLOCA)
>>> # if defined __GNUC__
>>> # define alloca __builtin_alloca
>>> # elif defined _AIX
>>> # define alloca __alloca
>>> # else
>>> # include <stddef.h>
>>> # ifdef __cplusplus
>>> extern "C"
>>> # endif
>>> extern "C"
>>> # endif
>>> void *alloca (size_t);
>>> # endif
>>> #endif
>
>> Then again, since AC_FUNC_ALLOCA does indeed set HAVE_ALLOCA via
>> AC_DEFINE, your patch proposal probably makes sense.
>
> Actually, your patch is not quite right - to get alloca on FreeBSD,
> you still have to include the right system headers. The
> AC_FUNC_ALLOCA macro is already including <stdlib.h> at configure
> time, by virtue of AC_INCLUDES_DEFAULT, but your C code must do the
> same. I don't see a problem with the configure test having a
> redundant redeclaration, without evidence of it causing a false
> negative test result, but agree that we might as well avoid the
> redundant declaration in user code. Here's what I will be pushing.
>
> ChangeLog | 5 +++++
> doc/autoconf.texi | 14 ++++++++++++--
> 2 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index c874eab..8fa6874 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,10 @@
> 2010-09-08 Eric Blake <address@hidden>
>
> + docs: update alloca recommendations
> + * doc/autoconf.texi (Particular Functions): Don't redeclare alloca
> + on FreeBSD.
> + Reported by Giorgos Keramidas.
> +
> docs: link to GNU Coding Standards in intro
> * doc/autoconf.texi (Introduction): Actually link to the
> standards. Make other references consistent.
> diff --git a/doc/autoconf.texi b/doc/autoconf.texi
> index 99054c5..780e93a 100644
> --- a/doc/autoconf.texi
> +++ b/doc/autoconf.texi
> @@ -4816,6 +4816,14 @@ Particular Functions
>
> @example
> @group
> +#ifdef STDC_HEADERS
> +# include <stdlib.h>
> +# include <stddef.h>
> +#else
> +# ifdef HAVE_STDLIB_H
> +# include <stdlib.h>
> +# endif
> +#endif
> #ifdef HAVE_ALLOCA_H
> # include <alloca.h>
> #elif defined __GNUC__
> @@ -4827,10 +4835,12 @@ Particular Functions
> # define alloca _alloca
> #else
> # include <stddef.h>
> -# ifdef __cplusplus
> +# ifndef HAVE_ALLOCA
> +# ifdef __cplusplus
> extern "C"
> -# endif
> +# endif
> void *alloca (size_t);
> +# endif
> #endif
> @end group
> @end example