]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
AC_CHECK_ALIGNOF: fix cross-compilation bug with newer gcc
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 6 Sep 2012 21:50:27 +0000 (14:50 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 6 Sep 2012 21:55:09 +0000 (14:55 -0700)
* doc/autoconf.texi (Default Includes, Particular Functions)
(Header Portability):
* lib/autoconf/c.m4 (AC_LANG_FUNC_LINK_TRY(C)):
* lib/autoconf/headers.m4 (AC_HEADER_STDC):
* lib/autoconf/types.m4 (_AC_CHECK_ALIGNOF):
* lib/m4sugar/m4sugar.m4 (m4_require) [comment only]:
Assume the existence of the C89 freestanding headers <float.h>,
<limits.h>, <stdarg.h>, <stddef.h>, as that's safe nowadays.
This is less likely to run into gotchas, and should fix a
cross-compilation bug with newer GCC reported by Myke Frysinger in
<http://lists.gnu.org/archive/html/bug-autoconf/2012-09/msg00001.html>.

doc/autoconf.texi
lib/autoconf/c.m4
lib/autoconf/headers.m4
lib/autoconf/types.m4
lib/m4sugar/m4sugar.m4

index 3d2fe1aed49fa684444668a22b2e96a1daf812cb..7b8bfd59f0b689a0ee785363d10a7ca73f8f4435 100644 (file)
@@ -3885,14 +3885,10 @@ Expand to @var{include-directives} if defined, otherwise to:
 #ifdef HAVE_SYS_STAT_H
 # include <sys/stat.h>
 #endif
-#ifdef STDC_HEADERS
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
 # include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
 #endif
+#include <stddef.h>
 #ifdef HAVE_STRING_H
 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
 #  include <memory.h>
@@ -4862,14 +4858,10 @@ like the following, to declare it properly.
 
 @example
 @group
-#ifdef STDC_HEADERS
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
 # include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
 #endif
+#include <stddef.h>
 #ifdef HAVE_ALLOCA_H
 # include <alloca.h>
 #elif !defined alloca
@@ -5764,14 +5756,10 @@ beforehand.  One should run:
 AC_CHECK_HEADERS([sys/socket.h])
 AC_CHECK_HEADERS([net/if.h], [], [],
 [#include <stdio.h>
-#ifdef STDC_HEADERS
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
 # include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
 #endif
+#include <stddef.h>
 #ifdef HAVE_SYS_SOCKET_H
 # include <sys/socket.h>
 #endif
@@ -5787,14 +5775,10 @@ On Darwin, this file requires that @file{stdio.h} and
 AC_CHECK_HEADERS([sys/socket.h])
 AC_CHECK_HEADERS([netinet/if_ether.h], [], [],
 [#include <stdio.h>
-#ifdef STDC_HEADERS
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
 # include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
 #endif
+#include <stddef.h>
 #ifdef HAVE_SYS_SOCKET_H
 # include <sys/socket.h>
 #endif
index 7337245880ebd81895e8cd13bb98659dc5ecad55..e9946095582c2219a21efe742f7d4483a0447e65 100644 (file)
@@ -154,16 +154,9 @@ m4_define([AC_LANG_FUNC_LINK_TRY(C)],
 #define $1 innocuous_$1
 
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $1 (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
+   which can conflict with char $1 (); below.  */
 
+#include <limits.h>
 #undef $1
 
 /* Override any GCC internal prototype to avoid an error.
@@ -348,15 +341,9 @@ for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
 do
   # Use a header file that comes with gcc, so configuring glibc
   # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
-  _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@ifdef __STDC__
-@%:@ include <limits.h>
-@%:@else
-@%:@ include <assert.h>
-@%:@endif
+  _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <limits.h>
                     Syntax error]])],
                     [],
                     [# Broken: fails on valid input.
index 81a7fa242ab1e30868a02cdf6484293655069d4b..58a27784c36815062a285786f0ddba5f92a05f82 100644 (file)
@@ -306,14 +306,10 @@ ac_includes_default="\
 #ifdef HAVE_SYS_STAT_H
 # include <sys/stat.h>
 #endif
-#ifdef STDC_HEADERS
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
 # include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
 #endif
+#include <stddef.h>
 #ifdef HAVE_STRING_H
 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
 #  include <memory.h>
index 18fc175390678de1c4f97860e64dcf83737c2df6..f9ba33d7bef1c7efc8b69b7fbce7bd5062454715 100644 (file)
@@ -808,9 +808,6 @@ m4_define([_AC_CHECK_ALIGNOF],
 _AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$3])],
   [(long int) offsetof (ac__type_alignof_, y)],
   [AC_INCLUDES_DEFAULT([$2])
-#ifndef offsetof
-# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
-#endif
 typedef struct { char x; $1 y; } ac__type_alignof_;],
   [if test "$AS_TR_SH([ac_cv_type_$3])" = yes; then
      AC_MSG_FAILURE([cannot compute alignment of $1], 77)
index 278bc0518208320396f6363305d72c3eed376437..12a9ab74ef761796713d5b61889d2de4f6bc1fd2 100644 (file)
@@ -2038,10 +2038,10 @@ m4_define([m4_before],
 # - NAME-TO-CHECK == BODY-TO-EXPAND
 #   Which you can use for regular macros with or without arguments, e.g.,
 #     m4_require([AC_PROG_CC], [AC_PROG_CC])
-#     m4_require([AC_CHECK_HEADERS(limits.h)], [AC_CHECK_HEADERS(limits.h)])
+#     m4_require([AC_CHECK_HEADERS(threads.h)], [AC_CHECK_HEADERS(threads.h)])
 #   which is just the same as
 #     m4_require([AC_PROG_CC])
-#     m4_require([AC_CHECK_HEADERS(limits.h)])
+#     m4_require([AC_CHECK_HEADERS(threads.h)])
 #
 # - BODY-TO-EXPAND == m4_indir([NAME-TO-CHECK])
 #   In the case of macros with irregular names.  For instance: