From: Guy Harris Date: Mon, 22 Jan 2018 01:59:07 +0000 (-0800) Subject: Don't test for __attribute__ in the configure script. X-Git-Tag: libpcap-1.9-bp~275 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/4e84397255c98aa19f83bb1359a33fab1d15397f Don't test for __attribute__ in the configure script. Instead, use compiler test macros for the one remaining case where we tested for __attribute__ to check whether that *particular* attribute is supported. --- diff --git a/aclocal.m4 b/aclocal.m4 index 243203c4..3689f6c8 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1062,36 +1062,3 @@ AC_DEFUN(AC_LBL_LIBRARY_NET, [ # DLPI needs putmsg under HPUX so test for -lstr while we're at it AC_SEARCH_LIBS(putmsg, str) ]) - -dnl -dnl Test for __attribute__ -dnl - -AC_DEFUN(AC_C___ATTRIBUTE__, [ -AC_MSG_CHECKING(for __attribute__) -AC_CACHE_VAL(ac_cv___attribute__, [ -AC_COMPILE_IFELSE([ - AC_LANG_SOURCE([[ -#include - -static void foo(void) __attribute__ ((noreturn)); - -static void -foo(void) -{ - exit(1); -} - -int -main(int argc, char **argv) -{ - foo(); -} - ]])], -ac_cv___attribute__=yes, -ac_cv___attribute__=no)]) -if test "$ac_cv___attribute__" = "yes"; then - AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__]) -fi -AC_MSG_RESULT($ac_cv___attribute__) -]) diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index a406cd94..095bcf8e 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -244,9 +244,6 @@ /* Define to 1 if you have the `PacketIsLoopbackAdapter' function. */ #cmakedefine HAVE_PACKET_IS_LOOPBACK_ADAPTER 1 -/* define if your compiler has __attribute__ */ -#cmakedefine HAVE___ATTRIBUTE__ 1 - /* IPv6 */ #cmakedefine INET6 1 diff --git a/config.h.in b/config.h.in index 13d0bd7e..042fb756 100644 --- a/config.h.in +++ b/config.h.in @@ -244,9 +244,6 @@ /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF -/* define if your compiler has __attribute__ */ -#undef HAVE___ATTRIBUTE__ - /* IPv6 */ #undef INET6 diff --git a/configure b/configure index 7428e08b..c9bb8a83 100755 --- a/configure +++ b/configure @@ -4070,50 +4070,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__" >&5 -$as_echo_n "checking for __attribute__... " >&6; } -if ${ac_cv___attribute__+:} false; then : - $as_echo_n "(cached) " >&6 -else - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - -#include - -static void foo(void) __attribute__ ((noreturn)); - -static void -foo(void) -{ - exit(1); -} - -int -main(int argc, char **argv) -{ - foo(); -} - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv___attribute__=yes -else - ac_cv___attribute__=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - -if test "$ac_cv___attribute__" = "yes"; then - -$as_echo "#define HAVE___ATTRIBUTE__ 1" >>confdefs.h - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute__" >&5 -$as_echo "$ac_cv___attribute__" >&6; } - - # # Try to arrange for large file support. # diff --git a/configure.ac b/configure.ac index b008689f..5e46cf54 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,6 @@ AC_PROG_CC_C99 AC_LBL_C_INIT(V_CCOPT, V_INCLS) AC_LBL_SHLIBS_INIT AC_LBL_C_INLINE -AC_C___ATTRIBUTE__ # # Try to arrange for large file support. diff --git a/extract.h b/extract.h index 8a8b6024..aa3ff991 100644 --- a/extract.h +++ b/extract.h @@ -24,6 +24,7 @@ #endif #include +#include /* * Macros to extract possibly-unaligned big-endian integral values. @@ -32,15 +33,16 @@ /* * The processor doesn't natively handle unaligned loads. */ -#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \ +#if PCAP_IS_AT_LEAST_GNUC_VERSION(2,0) && \ (defined(__alpha) || defined(__alpha__) || \ defined(__mips) || defined(__mips__)) - /* - * This is a GCC-compatible compiler and we have __attribute__, which - * we assume that mean we have __attribute__((packed)), and this is - * MIPS or Alpha, which has instructions that can help when doing - * unaligned loads. + * This is MIPS or Alpha, which don't natively handle unaligned loads, + * but which have instructions that can help when doing unaligned + * loads, and this is GCC 2.0 or later or a compiler that claims to + * be GCC 2.0 or later, which we assume that mean we have + * __attribute__((packed)), which we can use to convince the compiler + * to generate those instructions. * * Declare packed structures containing a uint16_t and a uint32_t, * cast the pointer to point to one of those, and fetch through it;