From f8bf5e01f76620cc550253cc2575754872cf64aa Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 11 Oct 2024 09:57:49 +0900 Subject: [PATCH] build: Use AC_C_BIGENDIAN for detecting endian. * acinclude.m4 (GNUPG_CHECK_ENDIAN): Remove. * configure.ac (BIG_ENDIAN_HOST): Use AC_C_BIGENDIAN to detect endian and set BIG_ENDIAN_HOST. -- Reported-by: Alan Coopersmith Signed-off-by: NIIBE Yutaka --- acinclude.m4 | 61 ---------------------------------------------------- configure.ac | 26 ++++------------------ 2 files changed, 4 insertions(+), 83 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 98a87f673..d0d8e7e15 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -53,67 +53,6 @@ AC_DEFUN([GNUPG_CHECK_GNUMAKE], ]) -dnl GNUPG_CHECK_ENDIAN -dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST -dnl -AC_DEFUN([GNUPG_CHECK_ENDIAN], - [ - tmp_assumed_endian=big - tmp_assume_warn="" - if test "$cross_compiling" = yes; then - case "$host_cpu" in - i@<:@345678@:>@* ) - tmp_assumed_endian=little - ;; - *) - ;; - esac - fi - AC_MSG_CHECKING(endianness) - AC_CACHE_VAL(gnupg_cv_c_endian, - [ gnupg_cv_c_endian=unknown - # See if sys/param.h defines the BYTE_ORDER macro. - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include - #include ]], [[ - #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN - bogus endian macros - #endif]])], [# It does; now see whether it defined to BIG_ENDIAN or not. - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include - #include ]], [[ - #if BYTE_ORDER != BIG_ENDIAN - not big endian - #endif]])], gnupg_cv_c_endian=big, gnupg_cv_c_endian=little)]) - if test "$gnupg_cv_c_endian" = unknown; then - AC_RUN_IFELSE([AC_LANG_SOURCE([[main () { - /* Are we little or big endian? From Harbison&Steele. */ - union - { - long l; - char c[sizeof (long)]; - } u; - u.l = 1; - exit (u.c[sizeof (long) - 1] == 1); - }]])], - gnupg_cv_c_endian=little, - gnupg_cv_c_endian=big, - gnupg_cv_c_endian=$tmp_assumed_endian - tmp_assumed_warn=" (assumed)" - ) - fi - ]) - AC_MSG_RESULT([${gnupg_cv_c_endian}${tmp_assumed_warn}]) - if test "$gnupg_cv_c_endian" = little; then - AC_DEFINE(LITTLE_ENDIAN_HOST,1, - [Defined if the host has little endian byte ordering]) - else - AC_DEFINE(BIG_ENDIAN_HOST,1, - [Defined if the host has big endian byte ordering]) - fi - ]) - - - - # GNUPG_BUILD_PROGRAM(NAME,DEFAULT) # Add a --enable-NAME option to configure an set the # shell variable build_NAME either to "yes" or "no". DEFAULT must diff --git a/configure.ac b/configure.ac index 991313093..36ff452d7 100644 --- a/configure.ac +++ b/configure.ac @@ -544,19 +544,6 @@ AH_BOTTOM([ #endif -/* We didn't define endianness above, so get it from OS macros. This - is intended for making fat binary builds on OS X. */ -#if !defined(BIG_ENDIAN_HOST) && !defined(LITTLE_ENDIAN_HOST) -#if defined(__BIG_ENDIAN__) -#define BIG_ENDIAN_HOST 1 -#elif defined(__LITTLE_ENDIAN__) -#define LITTLE_ENDIAN_HOST 1 -#else -#error "No endianness found" -#endif -#endif - - /* Hack used for W32: ldap.m4 also tests for the ASCII version of ldap_start_tls_s because that is the actual symbol used in the library. winldap.h redefines it to our commonly used value, @@ -1332,6 +1319,10 @@ AC_MSG_NOTICE([checking for system characteristics]) AC_C_CONST AC_C_INLINE AC_C_VOLATILE +AC_C_BIGENDIAN([AC_DEFINE(BIG_ENDIAN_HOST,1, + [Defined if the host has big endian byte ordering])], + [AC_DEFINE(LITTLE_ENDIAN_HOST,1, + [Defined if the host has little endian byte ordering])]) AC_TYPE_SIZE_T AC_TYPE_MODE_T AC_CHECK_FUNCS([sigdescr_np]) @@ -1347,15 +1338,6 @@ gl_TYPE_SOCKLEN_T AC_SEARCH_LIBS([inet_addr], [nsl]) -AC_ARG_ENABLE(endian-check, - AS_HELP_STRING([--disable-endian-check], - [disable the endian check and trust the OS provided macros]), - endiancheck=$enableval,endiancheck=yes) - -if test x"$endiancheck" = xyes ; then - GNUPG_CHECK_ENDIAN -fi - # fixme: we should get rid of the byte type AC_CHECK_TYPES([byte, ushort, ulong, u16, u32]) AC_CHECK_SIZEOF(unsigned short)