summaryrefslogtreecommitdiff
path: root/insert_string_tpl.h
diff options
context:
space:
mode:
authorHans Kristian Rosbach <hk-git@circlestorm.org>2024-12-17 23:09:31 +0100
committerHans Kristian Rosbach <hk-git@circlestorm.org>2024-12-17 23:09:31 +0100
commit037ab0fd3505baf38fdccb8c23dcc4e5614936f1 (patch)
treeef1813e6dfbeee03b01156404456cb81c23fd713 /insert_string_tpl.h
parent80fffd72f316df980bb15ea0daf06ba22e3583ec (diff)
downloadProject-Tick-037ab0fd3505baf38fdccb8c23dcc4e5614936f1.tar.gz
Project-Tick-037ab0fd3505baf38fdccb8c23dcc4e5614936f1.zip
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.
Diffstat (limited to 'insert_string_tpl.h')
-rw-r--r--insert_string_tpl.h18
1 files changed, 13 insertions, 5 deletions
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