]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Make use of unaligned loads on big endian in insert_string
authorCameron Cawley <ccawley2011@gmail.com>
Sun, 25 Feb 2024 18:08:53 +0000 (18:08 +0000)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sun, 15 Sep 2024 14:07:50 +0000 (16:07 +0200)
insert_string_tpl.h

index 281c0134631048c75fd10571a2aef2cbcb112a56..a5685c4ed7de3da269687d13b57f035011e8fd66 100644 (file)
 #  define HASH_CALC_MASK HASH_MASK
 #endif
 #ifndef HASH_CALC_READ
-#  if BYTE_ORDER == LITTLE_ENDIAN
-#    define HASH_CALC_READ \
-        memcpy(&val, strstart, sizeof(val));
+#  ifdef UNALIGNED_OK
+#    if BYTE_ORDER == LITTLE_ENDIAN
+#      define HASH_CALC_READ \
+          memcpy(&val, strstart, sizeof(val));
+#    else
+#      define HASH_CALC_READ \
+          memcpy(&val, strstart, sizeof(val)); \
+          val = ZSWAP32(val);
+#    endif
 #  else
 #    define HASH_CALC_READ \
         val  = ((uint32_t)(strstart[0])); \