]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix compilation of match.c on big-endian machines, and avoid
authorroot <root@hk.drivdigital.no>
Thu, 11 Dec 2014 13:30:51 +0000 (14:30 +0100)
committerroot <root@hk.drivdigital.no>
Thu, 11 Dec 2014 13:30:51 +0000 (14:30 +0100)
usage of unoptimized builtins.

match.c

diff --git a/match.c b/match.c
index 5198c85b43cf00c219da33ca364e55f84b177cfe..541f77c4f99cc159d84a7421817f38b4009f07bb 100644 (file)
--- a/match.c
+++ b/match.c
@@ -9,19 +9,23 @@
  */
 
 #include <stdint.h>
-
 #include "deflate.h"
 
 #if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
-#  if defined(HAVE_BUILTIN_CTZL)
+
+   /* Only use std3_longest_match for little_endian systems, also avoid using it with
+      non-gcc compilers since the __builtin_ctzl() function might not be optimized. */
+#  if defined(__GNUC__) && defined(HAVE_BUILTIN_CTZL) && ((__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN__))
 #    define std3_longest_match
 #  else
 #    define std2_longest_match
 #  endif
+
 #else
 #  define std1_longest_match
 #endif
 
+
 #ifdef std1_longest_match
 
 /*