From: Vladislav Shchapov Date: Sat, 3 Feb 2024 16:32:28 +0000 (+0500) Subject: Move select for generic functions into generic_functions.h. X-Git-Tag: 2.2.0~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=305b268b324431ff9cce3c2e17faa1551530fc7f;p=thirdparty%2Fzlib-ng.git Move select for generic functions into generic_functions.h. Signed-off-by: Vladislav Shchapov --- diff --git a/arch/generic/generic_functions.h b/arch/generic/generic_functions.h index a12b47ce..debc4b58 100644 --- a/arch/generic/generic_functions.h +++ b/arch/generic/generic_functions.h @@ -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 diff --git a/functable.c b/functable.c index 8905c16c..348f45ca 100644 --- a/functable.c +++ b/functable.c @@ -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