]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Disable unaligned access of > 4 bytes on 32-bit arm
authorNiLuJe <ninuje@gmail.com>
Thu, 4 Jun 2020 22:48:06 +0000 (00:48 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 9 Jun 2020 06:29:22 +0000 (08:29 +0200)
CMakeLists.txt
compare258.c
configure
functable.c
win32/Makefile.a64
win32/Makefile.msc

index 4d1fac044410f22595675fac8d1477d130841eed..a54dda5d5d3b6ae68083af1648dece65bfd0eebc 100644 (file)
@@ -266,6 +266,29 @@ if(UNALIGNED_OK)
     add_definitions(-DUNALIGNED_OK)
     message(STATUS "Architecture supports unaligned reads")
 endif()
+if(BASEARCH_ARM_FOUND)
+    if(NOT DEFINED UNALIGNED64_OK)
+        if("${ARCH}" MATCHES "(arm(v[8-9])?|aarch64)")
+            set(UNALIGNED64_OK TRUE)
+        endif()
+    endif()
+endif()
+if(BASEARCH_PPC_FOUND)
+    if(NOT DEFINED UNALIGNED64_OK)
+        if("${ARCH}" MATCHES "powerpc64le")
+            set(UNALIGNED64_OK TRUE)
+        endif()
+    endif()
+endif()
+if(BASEARCH_X86_FOUND)
+    if(NOT DEFINED UNALIGNED64_OK)
+        set(UNALIGNED64_OK TRUE)
+    endif()
+endif()
+if(UNALIGNED64_OK)
+    add_definitions(-DUNALIGNED64_OK)
+    message(STATUS "Architecture supports unaligned reads of > 4 bytes")
+endif()
 
 # Apply warning flags to cflags
 if(WITH_MAINTAINER_WARNINGS)
@@ -1134,7 +1157,7 @@ if(ZLIB_ENABLE_TESTS)
         endforeach()
     endforeach()
 
-    minigzip_stdio_cmp(minigzip "detect-text" "test/data/lcet10.txt" -A)       
+    minigzip_stdio_cmp(minigzip "detect-text" "test/data/lcet10.txt" -A)
     minigzip_stdio_cmp(minigzip "detect-binary" "test/data/paper-100k.pdf" -A)
 
     if(NOT WIN32 AND ZLIB_COMPAT)
index cb75d0974d4f820c942098424819bc6fcd6a46a2..2b07998677debb5d6953ccd855a15a9cc6eee282 100644 (file)
@@ -143,8 +143,8 @@ int32_t compare258_unaligned_32(const unsigned char *src0, const unsigned char *
 
 #endif
 
-#ifdef HAVE_BUILTIN_CTZLL
-/* UNALIGNED_OK, 64-bit integer comparison */
+#if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL)
+/* UNALIGNED64_OK, 64-bit integer comparison */
 static inline int32_t compare256_unaligned_64_static(const unsigned char *src0, const unsigned char *src1) {
     int32_t len = 0;
 
index c2cd6f1709e686ed9596d39157732d5e858f7793..c8ca3bfdd4791d26c1057a0dc6bb179c9c36dbe5 100755 (executable)
--- a/configure
+++ b/configure
@@ -1099,8 +1099,8 @@ case "${ARCH}" in
     i386 | i486 | i586 | i686)
         ARCHDIR=arch/x86
 
-        CFLAGS="${CFLAGS} -DUNALIGNED_OK"
-        SFLAGS="${SFLAGS} -DUNALIGNED_OK"
+        CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
+        SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
 
         # Enable arch-specific optimizations?
         if test $without_optimizations -eq 0; then
@@ -1121,7 +1121,7 @@ case "${ARCH}" in
                     SFLAGS="${SFLAGS} -DX86_NOCHECK_SSE2"
                 fi
             fi
-            
+
             if test ${HAVE_SSSE3_INTRIN} -eq 1; then
                 CFLAGS="${CFLAGS} -DX86_SSSE3 -DX86_SSSE3_ADLER32"
                 SFLAGS="${SFLAGS} -DX86_SSSE3 -DX86_SSSE3_ADLER32"
@@ -1168,8 +1168,8 @@ case "${ARCH}" in
     x86_64)
         ARCHDIR=arch/x86
 
-        CFLAGS="${CFLAGS} -DUNALIGNED_OK"
-        SFLAGS="${SFLAGS} -DUNALIGNED_OK"
+        CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
+        SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
 
         # Enable arch-specific optimizations?
         if test $without_optimizations -eq 0; then
@@ -1283,8 +1283,8 @@ case "${ARCH}" in
                 fi
             ;;
             armv8-a | armv8-a+simd)
-                CFLAGS="${CFLAGS} -DUNALIGNED_OK"
-                SFLAGS="${SFLAGS} -DUNALIGNED_OK"
+                CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
+                SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
 
                 if test $without_optimizations -eq 0; then
                     if test $buildacle -eq 1; then
@@ -1306,8 +1306,8 @@ case "${ARCH}" in
                 fi
             ;;
             armv8-a+crc | armv8-a+crc+simd | armv8.[1234]-a | armv8.[1234]-a+simd)
-                CFLAGS="-march=${ARCH} ${CFLAGS} -DUNALIGNED_OK"
-                SFLAGS="-march=${ARCH} ${SFLAGS} -DUNALIGNED_OK"
+                CFLAGS="-march=${ARCH} ${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
+                SFLAGS="-march=${ARCH} ${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
 
                 if test $without_optimizations -eq 0; then
                     CFLAGS="${CFLAGS} -DARM_ACLE_CRC_HASH"
@@ -1370,8 +1370,8 @@ case "${ARCH}" in
             fi
         fi
 
-        CFLAGS="-march=${ARCH} ${CFLAGS} -DUNALIGNED_OK"
-        SFLAGS="-march=${ARCH} ${SFLAGS} -DUNALIGNED_OK"
+        CFLAGS="-march=${ARCH} ${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
+        SFLAGS="-march=${ARCH} ${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
     ;;
     powerpc*)
         case "${ARCH}" in
@@ -1383,8 +1383,8 @@ case "${ARCH}" in
             ;;
             powerpc64le)
                 [ ! -z $CROSS_PREFIX ] && QEMU_ARCH=ppc64le
-                CFLAGS="${CFLAGS} -DUNALIGNED_OK"
-                SFLAGS="${SFLAGS} -DUNALIGNED_OK"
+                CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
+                SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNALIGNED64_OK"
             ;;
         esac
 
index 4ba575cfdb85212b16bfa74b9aeb69c1d8200fb4..81249656d834c0ea290709b7ef1cc2e6c046ae37 100644 (file)
@@ -72,7 +72,9 @@ extern int32_t compare258_c(const unsigned char *src0, const unsigned char *src1
 #ifdef UNALIGNED_OK
 extern int32_t compare258_unaligned_16(const unsigned char *src0, const unsigned char *src1);
 extern int32_t compare258_unaligned_32(const unsigned char *src0, const unsigned char *src1);
+#ifdef UNALIGNED64_OK
 extern int32_t compare258_unaligned_64(const unsigned char *src0, const unsigned char *src1);
+#endif
 #ifdef X86_SSE42_CMP_STR
 extern int32_t compare258_unaligned_sse4(const unsigned char *src0, const unsigned char *src1);
 #endif
@@ -86,7 +88,9 @@ extern int32_t longest_match_c(deflate_state *const s, Pos cur_match);
 #ifdef UNALIGNED_OK
 extern int32_t longest_match_unaligned_16(deflate_state *const s, Pos cur_match);
 extern int32_t longest_match_unaligned_32(deflate_state *const s, Pos cur_match);
+#ifdef UNALIGNED64_OK
 extern int32_t longest_match_unaligned_64(deflate_state *const s, Pos cur_match);
+#endif
 #ifdef X86_SSE42_CMP_STR
 extern int32_t longest_match_unaligned_sse4(deflate_state *const s, Pos cur_match);
 #endif
@@ -245,7 +249,7 @@ ZLIB_INTERNAL int32_t compare258_stub(const unsigned char *src0, const unsigned
     functable.compare258 = &compare258_c;
 
 #ifdef UNALIGNED_OK
-#  ifdef HAVE_BUILTIN_CTZLL
+#  if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL)
     functable.compare258 = &compare258_unaligned_64;
 #  elif defined(HAVE_BUILTIN_CTZ)
     functable.compare258 = &compare258_unaligned_32;
@@ -270,7 +274,7 @@ ZLIB_INTERNAL int32_t longest_match_stub(deflate_state *const s, Pos cur_match)
     functable.longest_match = &longest_match_c;
 
 #ifdef UNALIGNED_OK
-#  ifdef HAVE_BUILTIN_CTZLL
+#  if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL)
     functable.longest_match = &longest_match_unaligned_64;
 #  elif defined(HAVE_BUILTIN_CTZ)
     functable.longest_match = &longest_match_unaligned_32;
index b27aa8fc8ba747874e3bc607481b21e7879acbe3..6821098ca810190beec6ff45d37029efef24b82b 100644 (file)
@@ -23,7 +23,7 @@ AR = lib
 RC = rc
 CP = copy /y
 CFLAGS  = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC)
-WFLAGS  = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DUNALIGNED_OK -D_ARM64_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1
+WFLAGS  = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DUNALIGNED_OK -DUNALIGNED64_OK -D_ARM64_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1
 LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest
 ARFLAGS = -nologo
 RCFLAGS = /dARM64 /r
index 1e343bb8956a609c59f19a0bb6d872e99d1bd23c..9bfb70fb757065274fd5cbd6654776ac6b959ebe 100644 (file)
@@ -23,7 +23,7 @@ AR = lib
 RC = rc
 CP = copy /y
 CFLAGS  = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC)
-WFLAGS  = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DX86_PCLMULQDQ_CRC -DX86_SSE2 -DX86_CPUID -DX86_SSE42_CRC_INTRIN -DX86_SSE42_CRC_HASH -DX86_AVX2 -DUNALIGNED_OK
+WFLAGS  = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DX86_PCLMULQDQ_CRC -DX86_SSE2 -DX86_CPUID -DX86_SSE42_CRC_INTRIN -DX86_SSE42_CRC_HASH -DX86_AVX2 -DUNALIGNED_OK -DUNALIGNED64_OK
 LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest
 ARFLAGS = -nologo
 RCFLAGS = /dWIN32 /r