emacs-devel
[Top][All Lists]
Advanced

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

Re: alloca() warnings on freebsd


From: Giorgos Keramidas
Subject: Re: alloca() warnings on freebsd
Date: Tue, 07 Sep 2010 22:01:16 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix)

On Tue, 10 Aug 2010 12:38:14 +0300, Giorgos Keramidas <address@hidden> wrote:
> On Mon, 09 Aug 2010 19:16:33 -0400, Dan Nicolaescu <address@hidden> wrote:
>> Giorgos Keramidas <address@hidden> writes:
>>> Some time during the recent past an alloca() prototype was introduced to
>>> config.h that conflicts with the stdlib.h prototype of alloca() on my
>>> FreeBSD laptop.
>>>
>>> The current check near line 1148 of config.in is:
>>>
>>>     #ifdef HAVE_ALLOCA_H
>>>     # include <alloca.h>
>>>     #elif defined __GNUC__
>>>     # define alloca __builtin_alloca
>>>     #elif defined _AIX
>>>     # define alloca __alloca
>>>     #else
>>>     # include <stddef.h>
>>>     # ifdef  __cplusplus
>>>     extern "C"
>>>     # endif
>>>     void *alloca (size_t);
>>>     #endif
>
>> What we use now is a shorter version what the autoconf manual
>> recommends.  Could you ask the autoconf guys about this, and post the
>> solution here?  That would help fix the same problem for other
>> programs, not only for emacs.
>
> The manual version is indeed bogus.  It assumes that if __GNUC__ is
> defined, then __builtin_alloca() is always ok.  I'll try to contact the
> autoconf people.  In the meantime the patch seems to have fixed the
> alloca() warnigns on FreeBSD.  I'll keep it in my personal patch queue:
>
>   http://bitbucket.org/keramida/emacs-bsd-patches/src/tip/patch-alloca
>   http://bitbucket.org/keramida/emacs-bsd-patches/src/tip/patch-alloca-regen
>
> So when the autoconf people reply I'll followup with more details.

I've sent the following to the Autoconf bug list.  If they change
the Autoconf manual we can safely commit the modified version to
GNU Emacs too.

    From: Giorgos Keramidas <address@hidden>
    To: address@hidden
    Subject: alloca.h example in the manual
    Date: Tue, 07 Sep 2010 21:55:32 +0300
    Message-ID: <address@hidden>
    User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix)

    Hi all,

    The Autoconf manual (section 5.5.2, "Particular Function Checks")
    recommends the following check for source files that use the
    alloca() function:

        #ifdef HAVE_ALLOCA_H
        # include <alloca.h>
        #elif defined __GNUC__
        # define alloca __builtin_alloca
        #elif defined _AIX
        # define alloca __alloca
        #elif defined _MSC_VER
        # include <malloc.h>
        # define alloca _alloca
        #else
        # include <stddef.h>
        # ifdef  __cplusplus
        extern "C"
        # endif
        void *alloca (size_t);
        #endif

    There are systems where this breaks though, because alloca() is
    available as a function but not in a special 'alloca.h' header
    file.  For example, in FreeBSD, alloca() is defined in 'stdlib.h'
    and this means that HAVE_ALLOCA_H is undefined.  The result of the
    previous macro bits is that a redundant prototype of alloca() is
    declared.

    The modified version shown below declares a prototype of alloca()
    only when HAVE_ALLOCA is unset/undefined regardless of what
    HAVE_ALLOCA_H is set to:

        #ifdef HAVE_ALLOCA_H
        # include <alloca.h>
        #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
        void *alloca (size_t);
        # endif
        #endif

    This fixes the alloca() related warnings of at least GNU Emacs on
    my FreeBSD installations.  I've submitted the relevant changes to
    the GNU Emacs maintainers, but if we can fix the example in the
    autoconf manual too it would be really nice.




reply via email to

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