]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Unify detection of ARM getauxval code availability.
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Fri, 20 Sep 2019 20:50:50 +0000 (22:50 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sat, 21 Sep 2019 20:10:46 +0000 (22:10 +0200)
We don't want to compile arch-specific code when WITH_OPTIM is not set,
and the current checks don't take that into account.

CMakeLists.txt
deflate.c
functable.c
inflate.c
zutil.h

index cfa0806d75b9c5eb219ec48a598b2bbb41c9555b..a9a6a5a6f7e66f10fd753aad0f86af00ca09ae51 100644 (file)
@@ -521,6 +521,7 @@ endif()
 
 if(WITH_OPTIM)
     if(BASEARCH_ARM_FOUND)
+        add_definitions(-DARM_GETAUXVAL)
         list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/armfeature.c ${ARCHDIR}/fill_window_arm.c)
         if(WITH_NEON)
             list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/adler32_neon.c)
@@ -541,7 +542,7 @@ if(WITH_OPTIM)
             add_feature_info(ACLE_CRC 1 "Support CRC hash generation using the ACLE instruction set, using \"${ACLEFLAG}\"")
         endif()
     elseif(BASEARCH_X86_FOUND)
-        add_definitions("-DX86_CPUID")
+        add_definitions(-DX86_CPUID)
         list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/x86.c)
         if(HAVE_SSE42CRC_INLINE_ASM OR HAVE_SSE42CRC_INTRIN)
             add_definitions(-DX86_SSE42_CRC_HASH)
index 8ee4f1be9a1542b4c86c2a2dc22cded5e7d846e2..242c809eae0c6a245a367d18267eadebd79bb83d 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -266,9 +266,9 @@ int ZEXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int level, int method,
     int wrap = 1;
     static const char my_version[] = PREFIX2(VERSION);
 
-#ifdef X86_CPUID
+#if defined(X86_CPUID)
     x86_check_features();
-#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
+#elif defined(ARM_GETAUXVAL)
     arm_check_features();
 #endif
 
index 8ae6960529e9f4dc1d6892b8c0831897b77dfaed..fcdd34cd9bca584dedfbf3541e500ba68228586a 100644 (file)
@@ -17,9 +17,9 @@ extern Pos insert_string_acle(deflate_state *const s, const Pos str, unsigned in
 #endif
 
 /* fill_window */
-#ifdef X86_SSE2
+#if defined(X86_SSE2)
 extern void fill_window_sse(deflate_state *s);
-#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
+#elif defined(ARM_GETAUXVAL)
 extern void fill_window_arm(deflate_state *s);
 #endif
 
@@ -90,12 +90,12 @@ ZLIB_INTERNAL void fill_window_stub(deflate_state *s) {
     // Initialize default
     functable.fill_window=&fill_window_c;
 
-    #ifdef X86_SSE2
+    #if defined(X86_SSE2)
     # if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2)
     if (x86_cpu_has_sse2)
     # endif
         functable.fill_window=&fill_window_sse;
-    #elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
+    #elif defined(ARM_GETAUXVAL)
         functable.fill_window=&fill_window_arm;
     #endif
 
index fae8847d3d12013b9ec500ee93bf88246c7256ae..0b17e318d19b3fa10cc50a51082166508f7dd7fd 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -130,9 +130,9 @@ int ZEXPORT PREFIX(inflateInit2_)(PREFIX3(stream) *strm, int windowBits, const c
     int ret;
     struct inflate_state *state;
 
-#ifdef X86_CPUID
+#if defined(X86_CPUID)
     x86_check_features();
-#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || defined(_M_ARM64)
+#elif defined(ARM_GETAUXVAL)
     arm_check_features();
 #endif
 
diff --git a/zutil.h b/zutil.h
index 92f47063a6d58dd0c217506f8cb11b3d2f7e3ed0..9db42008865dd172a9ea3812a9697740a1b12168 100644 (file)
--- a/zutil.h
+++ b/zutil.h
@@ -240,7 +240,7 @@ void ZLIB_INTERNAL   zng_cfree(void *opaque, void *ptr);
 
 #if defined(X86_CPUID)
 # include "arch/x86/x86.h"
-#elif defined(__aarch64__) || defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)
+#elif defined(ARM_GETAUXVAL)
 # include "arch/arm/arm.h"
 #endif