From 037ab0fd3505baf38fdccb8c23dcc4e5614936f1 Mon Sep 17 00:00:00 2001 From: Hans Kristian Rosbach Date: Tue, 17 Dec 2024 23:09:31 +0100 Subject: Revert "Since we long ago make unaligned reads safe (by using memcpy or intrinsics)," This reverts commit 80fffd72f316df980bb15ea0daf06ba22e3583ec. It was mistakenly pushed to develop instead of going through a PR and the appropriate reviews. --- insert_string_tpl.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'insert_string_tpl.h') diff --git a/insert_string_tpl.h b/insert_string_tpl.h index e7037c04e6..a5685c4ed7 100644 --- a/insert_string_tpl.h +++ b/insert_string_tpl.h @@ -29,13 +29,21 @@ # 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 \ - memcpy(&val, strstart, sizeof(val)); \ - val = ZSWAP32(val); + val = ((uint32_t)(strstart[0])); \ + val |= ((uint32_t)(strstart[1]) << 8); \ + val |= ((uint32_t)(strstart[2]) << 16); \ + val |= ((uint32_t)(strstart[3]) << 24); # endif #endif -- cgit 0.0.5-2-1-g0f52