summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2016-11-04 14:22:50 (GMT)
committerYann Collet <cyan@fb.com>2016-11-04 14:24:21 (GMT)
commitf878c08b76a58e083c47470284139f3006c8e746 (patch)
tree82544df72128e541f2831f992e5df4ae12617754 /lib
parent26dec498cf1bae39f4842e93b8bfe4d10b0395e9 (diff)
downloadlz4-f878c08b76a58e083c47470284139f3006c8e746.zip
lz4-f878c08b76a58e083c47470284139f3006c8e746.tar.gz
lz4-f878c08b76a58e083c47470284139f3006c8e746.tar.bz2
better correctness on big-endian 64-bits platforms
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 0777d5e..b935b76 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -420,11 +420,15 @@ static U32 LZ4_hashSequence(U32 sequence, tableType_t const tableType)
return ((sequence * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG));
}
-static const U64 prime5bytes = 889523592379ULL;
static U32 LZ4_hashSequence64(U64 sequence, tableType_t const tableType)
{
+ static const U64 prime5bytes = 889523592379ULL;
+ static const U64 prime8bytes = 11400714785074694791ULL;
const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG;
- return ((sequence << 24) * prime5bytes) >> (64 - hashLog);
+ if (LZ4_isLittleEndian())
+ return ((sequence << 24) * prime5bytes) >> (64 - hashLog);
+ else
+ return ((sequence >> 24) * prime8bytes) >> (64 - hashLog);
}
static U32 LZ4_hashSequenceT(size_t sequence, tableType_t const tableType)