]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Move select for generic functions into generic_functions.h.
authorVladislav Shchapov <vladislav@shchapov.ru>
Sat, 3 Feb 2024 16:32:28 +0000 (21:32 +0500)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 22 Feb 2024 19:11:46 +0000 (20:11 +0100)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
arch/generic/generic_functions.h
functable.c

index a12b47cea5dd863b3653619c4e2b6bb41a9971bd..debc4b58456a2b365e755eb360f256b1200762e1 100644 (file)
@@ -65,4 +65,26 @@ uint32_t longest_match_slow_c(deflate_state *const s, Pos cur_match);
 #    endif
 #  endif
 
+
+// Select generic implementation for longest_match, longest_match_slow, longest_match_slow functions.
+#if defined(UNALIGNED_OK) && BYTE_ORDER == LITTLE_ENDIAN
+#  if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL)
+#    define longest_match_generic longest_match_unaligned_64
+#    define longest_match_slow_generic longest_match_slow_unaligned_64
+#    define compare256_generic compare256_unaligned_64
+#  elif defined(HAVE_BUILTIN_CTZ)
+#    define longest_match_generic longest_match_unaligned_32
+#    define longest_match_slow_generic longest_match_slow_unaligned_32
+#    define compare256_generic compare256_unaligned_32
+#  else
+#    define longest_match_generic longest_match_unaligned_16
+#    define longest_match_slow_generic longest_match_slow_unaligned_16
+#    define compare256_generic compare256_unaligned_16
+#  endif
+#else
+#  define longest_match_generic longest_match_c
+#  define longest_match_slow_generic longest_match_slow_c
+#  define compare256_generic compare256_c
+#endif
+
 #endif
index 8905c16ca1f62c114fde176e3f1733c7c17b8aa6..348f45ca334a69aa78a3049c98b725818877e92a 100644 (file)
@@ -4,7 +4,6 @@
  */
 
 #include "zbuild.h"
-#include "zendian.h"
 #include "functable.h"
 #include "cpu_features.h"
 #include "cpu_functions.h"
@@ -63,27 +62,9 @@ static void init_functable(void) {
     ft.quick_insert_string = &quick_insert_string_c;
     ft.slide_hash = &slide_hash_c;
     ft.update_hash = &update_hash_c;
-
-#if defined(UNALIGNED_OK) && BYTE_ORDER == LITTLE_ENDIAN
-#  if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL)
-    ft.longest_match = &longest_match_unaligned_64;
-    ft.longest_match_slow = &longest_match_slow_unaligned_64;
-    ft.compare256 = &compare256_unaligned_64;
-#  elif defined(HAVE_BUILTIN_CTZ)
-    ft.longest_match = &longest_match_unaligned_32;
-    ft.longest_match_slow = &longest_match_slow_unaligned_32;
-    ft.compare256 = &compare256_unaligned_32;
-#  else
-    ft.longest_match = &longest_match_unaligned_16;
-    ft.longest_match_slow = &longest_match_slow_unaligned_16;
-    ft.compare256 = &compare256_unaligned_16;
-#  endif
-#else
-    ft.longest_match = &longest_match_c;
-    ft.longest_match_slow = &longest_match_slow_c;
-    ft.compare256 = &compare256_c;
-#endif
-
+    ft.longest_match = &longest_match_generic;
+    ft.longest_match_slow = &longest_match_slow_generic;
+    ft.compare256 = &compare256_generic;
 
     // Select arch-optimized functions