all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* alloca() warnings on freebsd
@ 2010-08-09 22:09 Giorgos Keramidas
  2010-08-09 23:16 ` Dan Nicolaescu
  0 siblings, 1 reply; 4+ messages in thread
From: Giorgos Keramidas @ 2010-08-09 22:09 UTC (permalink / raw)
  To: emacs-devel

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

The tricky bit is that FreeBSD *does* have alloca() but not alloca.h, so
the final #else part declares a redundant prototype.  This causes a very
minor but frequent warning for all source files that include config.h:

    In file included from /hg/emacs/gker/lib-src/test-distrib.c:23:
    ../src/config.h:1152:1: warning: "alloca" redefined
    In file included from ../src/config.h:1146,
                     from /hg/emacs/gker/lib-src/test-distrib.c:23:
    /usr/include/stdlib.h:233:1: warning: this is the location of the previous definition
    ...

The attached patch is an attempt to fix this for FreeBSD without
breaking alloca() on other platforms.

Does it look ok for trunk?

%%%
diff -r eb8d82184a6f -r c422057d6385 ChangeLog
--- a/ChangeLog	Mon Aug 09 10:08:56 2010 -0700
+++ b/ChangeLog	Tue Aug 10 01:06:38 2010 +0300
@@ -1,3 +1,9 @@
+2010-08-09  Giorgos Keramidas  <keramida@ceid.upatras.gr>
+
+	* configure.in: Avoid declaring a redundant prototype of alloca()
+	when we HAVE_ALLOCA but not HAVE_ALLOCA_H (e.g. on FreeBSD systems
+	where alloca() is declared in stdlib.h).
+
 2010-08-09  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* configure.in (ORDINARY_LINK): Use on hpux* too.
diff -r eb8d82184a6f -r c422057d6385 configure.in
--- a/configure.in	Mon Aug 09 10:08:56 2010 -0700
+++ b/configure.in	Tue Aug 10 01:06:38 2010 +0300
@@ -3574,16 +3574,18 @@ SYSTEM_PURESIZE_EXTRA seems like the lea
 
 #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
+#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
-void *alloca (size_t);
 #endif
 
 #ifndef HAVE_SIZE_T
diff -r eb8d82184a6f -r c422057d6385 src/ChangeLog
--- a/src/ChangeLog	Mon Aug 09 10:08:56 2010 -0700
+++ b/src/ChangeLog	Tue Aug 10 01:06:38 2010 +0300
@@ -1,3 +1,9 @@
+2010-08-09  Giorgos Keramidas  <keramida@ceid.upatras.gr>
+
+	* config.in: Avoid declaring a redundant prototype of alloca()
+	when we HAVE_ALLOCA but not HAVE_ALLOCA_H (e.g. on FreeBSD systems
+	where alloca() is declared in stdlib.h).
+
 2010-08-09  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	Use const char* instead of char*.
diff -r eb8d82184a6f -r c422057d6385 src/config.in
--- a/src/config.in	Mon Aug 09 10:08:56 2010 -0700
+++ b/src/config.in	Tue Aug 10 01:06:38 2010 +0300
@@ -1147,16 +1147,18 @@ SYSTEM_PURESIZE_EXTRA seems like the lea
 
 #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
+#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
-void *alloca (size_t);
 #endif
 
 #ifndef HAVE_SIZE_T
%%%



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: alloca() warnings on freebsd
  2010-08-09 22:09 alloca() warnings on freebsd Giorgos Keramidas
@ 2010-08-09 23:16 ` Dan Nicolaescu
  2010-08-10  9:38   ` Giorgos Keramidas
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Nicolaescu @ 2010-08-09 23:16 UTC (permalink / raw)
  To: Giorgos Keramidas; +Cc: emacs-devel

Giorgos Keramidas <keramida@ceid.upatras.gr> 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
>
> The tricky bit is that FreeBSD *does* have alloca() but not alloca.h, so
> the final #else part declares a redundant prototype.  This causes a very
> minor but frequent warning for all source files that include config.h:
>
>     In file included from /hg/emacs/gker/lib-src/test-distrib.c:23:
>     ../src/config.h:1152:1: warning: "alloca" redefined
>     In file included from ../src/config.h:1146,
>                      from /hg/emacs/gker/lib-src/test-distrib.c:23:
>     /usr/include/stdlib.h:233:1: warning: this is the location of the previous definition
>     ...
>
> The attached patch is an attempt to fix this for FreeBSD without
> breaking alloca() on other platforms.
>
> Does it look ok for trunk?

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.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: alloca() warnings on freebsd
  2010-08-09 23:16 ` Dan Nicolaescu
@ 2010-08-10  9:38   ` Giorgos Keramidas
  2010-09-07 19:01     ` Giorgos Keramidas
  0 siblings, 1 reply; 4+ messages in thread
From: Giorgos Keramidas @ 2010-08-10  9:38 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

On Mon, 09 Aug 2010 19:16:33 -0400, Dan Nicolaescu <dann@gnu.org> wrote:
> Giorgos Keramidas <keramida@ceid.upatras.gr> 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.

Thanks,
Giorgos




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: alloca() warnings on freebsd
  2010-08-10  9:38   ` Giorgos Keramidas
@ 2010-09-07 19:01     ` Giorgos Keramidas
  0 siblings, 0 replies; 4+ messages in thread
From: Giorgos Keramidas @ 2010-09-07 19:01 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

On Tue, 10 Aug 2010 12:38:14 +0300, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> On Mon, 09 Aug 2010 19:16:33 -0400, Dan Nicolaescu <dann@gnu.org> wrote:
>> Giorgos Keramidas <keramida@ceid.upatras.gr> 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 <gkeramidas@gmail.com>
    To: bug-autoconf@gnu.org
    Subject: alloca.h example in the manual
    Date: Tue, 07 Sep 2010 21:55:32 +0300
    Message-ID: <87pqwpo02j.fsf@kobe.laptop>
    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.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-09-07 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-09 22:09 alloca() warnings on freebsd Giorgos Keramidas
2010-08-09 23:16 ` Dan Nicolaescu
2010-08-10  9:38   ` Giorgos Keramidas
2010-09-07 19:01     ` Giorgos Keramidas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.