]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Merge 32-bit arm hardware flag detection sections in configure and cmake
authorNathan Moinvaziri <nathan@nathanm.com>
Wed, 30 Aug 2023 14:29:46 +0000 (07:29 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 13 Sep 2023 09:55:01 +0000 (11:55 +0200)
CMakeLists.txt
configure

index 3679f9d6cd3e3b15460546416f57bfb89487c21a..f74c0e454d3238ad3b523f7109dc53ff5ecb2e83 100644 (file)
@@ -548,7 +548,20 @@ if(WITH_OPTIM)
     if(BASEARCH_ARM_FOUND)
         add_definitions(-DARM_FEATURES)
         if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
-            if(NOT "${ARCH}" MATCHES "aarch64")
+            if("${ARCH}" MATCHES "aarch64")
+                check_c_source_compiles(
+                    "#include <sys/auxv.h>
+                    int main() {
+                        return (getauxval(AT_HWCAP) & HWCAP_CRC32);
+                    }"
+                    ARM_AUXV_HAS_CRC32
+                )
+                if(ARM_AUXV_HAS_CRC32)
+                    add_definitions(-DARM_AUXV_HAS_CRC32)
+                else()
+                   message(STATUS "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime.")
+                endif()
+            else()
                 check_c_source_compiles(
                     "#include <sys/auxv.h>
                     int main() {
@@ -573,21 +586,6 @@ if(WITH_OPTIM)
                         message(STATUS "HWCAP2_CRC32 not present in sys/auxv.h; cannot detect support at runtime.")
                     endif()
                 endif()
-            else()
-                check_c_source_compiles(
-                    "#include <sys/auxv.h>
-                    int main() {
-                        return (getauxval(AT_HWCAP) & HWCAP_CRC32);
-                    }"
-                    ARM_AUXV_HAS_CRC32
-                )
-                if(ARM_AUXV_HAS_CRC32)
-                    add_definitions(-DARM_AUXV_HAS_CRC32)
-                else()
-                   message(STATUS "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime.")
-                endif()
-            endif()
-            if(NOT "${ARCH}" MATCHES "aarch64")
                 check_c_source_compiles(
                     "#include <sys/auxv.h>
                     int main() {
index b6339fbccb777f6d25330ca8c1483494c6e61131..46180548721521054e92346691a9f3d35b82b143 100755 (executable)
--- a/configure
+++ b/configure
@@ -1593,7 +1593,20 @@ EOF
             ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} arm_features.lo"
 
             if test $LINUX -eq 1; then
-                if test "$ARCH" != "aarch64"; then
+                if test "$ARCH" = "aarch64"; then
+                    cat > $test.c <<EOF
+#include <sys/auxv.h>
+int main() {
+    return (getauxval(AT_HWCAP) & HWCAP_CRC32);
+}
+EOF
+                    if try $CC -c $CFLAGS $test.c; then
+                        CFLAGS="${CFLAGS} -DARM_AUXV_HAS_CRC32"
+                        SFLAGS="${SFLAGS} -DARM_AUXV_HAS_CRC32"
+                    else
+                        echo "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log
+                    fi
+                else
                     cat > $test.c <<EOF
 #include <sys/auxv.h>
 int main() {
@@ -1618,22 +1631,7 @@ EOF
                             echo "HWCAP2_CRC32 not present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log
                         fi
                     fi
-                else
-                    cat > $test.c <<EOF
-#include <sys/auxv.h>
-int main() {
-    return (getauxval(AT_HWCAP) & HWCAP_CRC32);
-}
-EOF
-                    if try $CC -c $CFLAGS $test.c; then
-                        CFLAGS="${CFLAGS} -DARM_AUXV_HAS_CRC32"
-                        SFLAGS="${SFLAGS} -DARM_AUXV_HAS_CRC32"
-                    else
-                        echo "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime." | tee -a configure.log
-                    fi
-                fi
 
-                if test "$ARCH" != "aarch64"; then
                     cat > $test.c <<EOF
 #include <sys/auxv.h>
 int main() {