From: Nathan Moinvaziri Date: Tue, 13 Jan 2026 03:25:57 +0000 (-0800) Subject: Remove unnecessary ARM_AUXV_HAS_NEON preprocessor check X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c880d7bc3da6d8e3c5d630f35a34fe1313ab4fbe;p=thirdparty%2Fzlib-ng.git Remove unnecessary ARM_AUXV_HAS_NEON preprocessor check --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d666c278..c89f69cad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -742,52 +742,6 @@ if(WITH_OPTIM) add_definitions(-DWITH_OPTIM) if(BASEARCH_ARM_FOUND) add_definitions(-DARM_FEATURES) - if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - if(ARCH_32BIT) - check_c_source_compiles( - "#include - int main() { - return (getauxval(AT_HWCAP) & HWCAP_ARM_NEON); - }" - ARM_AUXV_HAS_NEON - ) - if(ARM_AUXV_HAS_NEON) - add_definitions(-DARM_AUXV_HAS_NEON) - else() - check_c_source_compiles( - "#include - int main() { - return (getauxval(AT_HWCAP) & HWCAP_NEON); - }" - ARM_AUXV_HAS_NEON - ) - if (ARM_AUXV_HAS_NEON) - add_definitions(-DARM_AUXV_HAS_NEON) - else() - message(STATUS "Neither HWCAP_ARM_NEON or HWCAP_NEON present in sys/auxv.h; cannot detect support at runtime.") - endif() - endif() - endif() - endif() - if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR - ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") - if(ARCH_32BIT) - check_c_source_compiles( - "#include - int main() { - unsigned long hwcap; - elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); - return (hwcap & HWCAP_NEON); - }" - ARM_AUXV_HAS_NEON - ) - if(ARM_AUXV_HAS_NEON) - add_definitions(-DARM_AUXV_HAS_NEON) - else() - message(STATUS "HWCAP_NEON not present in sys/auxv.h; cannot detect support at runtime.") - endif() - endif() - endif() list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm_functions.h) if(WITH_RUNTIME_CPU_DETECTION) list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm_features.h) diff --git a/arch/arm/arm_features.c b/arch/arm/arm_features.c index 3f035296c..6572fe703 100644 --- a/arch/arm/arm_features.c +++ b/arch/arm/arm_features.c @@ -150,17 +150,17 @@ static int arm_has_eor3(void) { #if defined(ARCH_ARM) && defined(ARCH_32BIT) static inline int arm_has_neon(void) { int has_neon = 0; -#if defined(ARM_AUXV_HAS_NEON) -# if defined(__FreeBSD__) || defined(__OpenBSD__) - unsigned long hwcap = 0; - elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); - has_neon = (hwcap & HWCAP_NEON) != 0; -# else -# ifdef HWCAP_ARM_NEON - has_neon = (getauxval(AT_HWCAP) & HWCAP_ARM_NEON) != 0; -# else - has_neon = (getauxval(AT_HWCAP) & HWCAP_NEON) != 0; -# endif +#if defined(__linux__) && defined(HAVE_SYS_AUXV_H) +# ifdef HWCAP_ARM_NEON + has_neon = (getauxval(AT_HWCAP) & HWCAP_ARM_NEON) != 0; +# elif defined(HWCAP_NEON) + has_neon = (getauxval(AT_HWCAP) & HWCAP_NEON) != 0; +# endif +#elif defined(__FreeBSD__) || defined(__OpenBSD__) +# ifdef HWCAP_NEON + unsigned long hwcap = 0; + elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); + has_neon = (hwcap & HWCAP_NEON) != 0; # endif #elif defined(__APPLE__) int has_feat = 0; diff --git a/configure b/configure index 6a4e5ffc2..42ab602f3 100755 --- a/configure +++ b/configure @@ -2059,54 +2059,6 @@ EOF echo "Checking for arm_acle.h... No." | tee -a configure.log fi - - if test $LINUX -eq 1; then - if test "$ARCH" != "aarch64"; then - cat > $test.c < -int main() { - return (getauxval(AT_HWCAP) & HWCAP_ARM_NEON); -} -EOF - if try $CC -c $CFLAGS $test.c; then - CFLAGS="${CFLAGS} -DARM_AUXV_HAS_NEON" - SFLAGS="${SFLAGS} -DARM_AUXV_HAS_NEON" - else - cat > $test.c < -int main() { - return (getauxval(AT_HWCAP) & HWCAP_NEON); -} -EOF - if try $CC -c $CFLAGS $test.c; then - CFLAGS="${CFLAGS} -DARM_AUXV_HAS_NEON" - SFLAGS="${SFLAGS} -DARM_AUXV_HAS_NEON" - else - echo "Neither HWCAP_ARM_NEON or HWCAP_NEON present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log - fi - fi - fi - fi - - if test $FREEBSD -eq 1 -o $OPENBSD -eq 1; then - if test "$ARCH" != "aarch64"; then - cat > $test.c < -int main() { - unsigned long hwcap; - elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); - return (hwcap & HWCAP_NEON); -} -EOF - if try $CC -c $CFLAGS $test.c; then - CFLAGS="${CFLAGS} -DARM_AUXV_HAS_NEON" - SFLAGS="${SFLAGS} -DARM_AUXV_HAS_NEON" - else - echo "HWCAP_NEON not present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log - fi - fi - fi - if test $buildneon -eq 1; then check_neon_compiler_flag