Fix murmurhash for big-endian architectures.
The murmurhash implementation tries to read a sequence of four bytes as a single little-endian uint32 value. This does not work on e.g. Linux/s390x; https://buildd.debian.org/status/fetch.php?pkg=kakoune&arch=s390x&ver=2021.11.08-1&stamp=1645975425&raw=0
This commit is contained in:
parent
6565f6edd7
commit
085973a486
|
@ -41,7 +41,11 @@ size_t hash_data(const char* input, size_t len)
|
||||||
for (ptrdiff_t i = -nblocks; i; ++i)
|
for (ptrdiff_t i = -nblocks; i; ++i)
|
||||||
{
|
{
|
||||||
uint32_t key;
|
uint32_t key;
|
||||||
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
memcpy(&key, blocks + 4*i, 4);
|
memcpy(&key, blocks + 4*i, 4);
|
||||||
|
#else
|
||||||
|
key = blocks[4*i] + (blocks[4*i + 1] << 8) + (blocks[4*i + 2] << 16) + (blocks[4*i + 3] << 24);
|
||||||
|
#endif
|
||||||
key *= c1;
|
key *= c1;
|
||||||
key = rotl(key, 15);
|
key = rotl(key, 15);
|
||||||
key *= c2;
|
key *= c2;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user