From: Paul Eggert Date: Thu, 6 Sep 2012 21:50:27 +0000 (-0700) Subject: AC_CHECK_ALIGNOF: fix cross-compilation bug with newer gcc X-Git-Tag: v2.69b~213 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f52459d158bcf5edd4ca75a453bb012efd0f4d90;p=thirdparty%2Fautoconf.git AC_CHECK_ALIGNOF: fix cross-compilation bug with newer gcc * 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 , , , , 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 . --- diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 3d2fe1ae..7b8bfd59 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -3885,14 +3885,10 @@ Expand to @var{include-directives} if defined, otherwise to: #ifdef HAVE_SYS_STAT_H # include #endif -#ifdef STDC_HEADERS +#if defined STDC_HEADERS || defined HAVE_STDLIB_H # include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif #endif +#include #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include @@ -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 -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif #endif +#include #ifdef HAVE_ALLOCA_H # include #elif !defined alloca @@ -5764,14 +5756,10 @@ beforehand. One should run: AC_CHECK_HEADERS([sys/socket.h]) AC_CHECK_HEADERS([net/if.h], [], [], [#include -#ifdef STDC_HEADERS +#if defined STDC_HEADERS || defined HAVE_STDLIB_H # include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif #endif +#include #ifdef HAVE_SYS_SOCKET_H # include #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 -#ifdef STDC_HEADERS +#if defined STDC_HEADERS || defined HAVE_STDLIB_H # include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif #endif +#include #ifdef HAVE_SYS_SOCKET_H # include #endif diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 73372458..e9946095 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -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 to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif + which can conflict with char $1 (); below. */ +#include #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 to if __STDC__ is defined, since - # 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 -@%:@else -@%:@ include -@%:@endif + _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include Syntax error]])], [], [# Broken: fails on valid input. diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4 index 81a7fa24..58a27784 100644 --- a/lib/autoconf/headers.m4 +++ b/lib/autoconf/headers.m4 @@ -306,14 +306,10 @@ ac_includes_default="\ #ifdef HAVE_SYS_STAT_H # include #endif -#ifdef STDC_HEADERS +#if defined STDC_HEADERS || defined HAVE_STDLIB_H # include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif #endif +#include #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4 index 18fc1753..f9ba33d7 100644 --- a/lib/autoconf/types.m4 +++ b/lib/autoconf/types.m4 @@ -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) diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4 index 278bc051..12a9ab74 100644 --- a/lib/m4sugar/m4sugar.m4 +++ b/lib/m4sugar/m4sugar.m4 @@ -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: