aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/check/crc64_fast.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-04-13 11:27:40 +0300
committerLasse Collin <lasse.collin@tukaani.org>2009-04-13 11:27:40 +0300
commit02ddf09bc3079b3e17297729b9e43f14d407b8fc (patch)
tree4a3b92a91c5eacbd7ea6229dd02ffeae6688b02f /src/liblzma/check/crc64_fast.c
parentFix off-by-one in LZ decoder. (diff)
downloadxz-02ddf09bc3079b3e17297729b9e43f14d407b8fc.tar.xz
Put the interesting parts of XZ Utils into the public domain.
Some minor documentation cleanups were made at the same time.
Diffstat (limited to 'src/liblzma/check/crc64_fast.c')
-rw-r--r--src/liblzma/check/crc64_fast.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/liblzma/check/crc64_fast.c b/src/liblzma/check/crc64_fast.c
index d2d1d60f..25557264 100644
--- a/src/liblzma/check/crc64_fast.c
+++ b/src/liblzma/check/crc64_fast.c
@@ -2,12 +2,15 @@
//
/// \file crc64.c
/// \brief CRC64 calculation
+///
+/// Calculate the CRC64 using the slice-by-four algorithm. This is the same
+/// idea that is used in crc32_fast.c, but for CRC64 we use only four tables
+/// instead of eight to avoid increasing CPU cache usage.
//
-// This code has been put into the public domain.
+// Author: Lasse Collin
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// This file has been put into the public domain.
+// You can do whatever you want with this file.
//
///////////////////////////////////////////////////////////////////////////////
@@ -22,7 +25,7 @@
#endif
-// See comments in crc32.c.
+// See the comments in crc32_fast.c. They aren't duplicated here.
extern LZMA_API(uint64_t)
lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
{
@@ -41,10 +44,6 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
const uint8_t *const limit = buf + (size & ~(size_t)(3));
size &= (size_t)(3);
- // Calculate the CRC64 using the slice-by-four algorithm.
- //
- // In contrast to CRC32 code, this one seems to be fastest
- // with -O3 -fomit-frame-pointer.
while (buf < limit) {
#ifdef WORDS_BIGENDIAN
const uint32_t tmp = (crc >> 32) ^ *(uint32_t *)(buf);
@@ -53,9 +52,6 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
#endif
buf += 4;
- // It is critical for performance, that
- // the crc variable is XORed between the
- // two table-lookup pairs.
crc = lzma_crc64_table[3][A(tmp)]
^ lzma_crc64_table[2][B(tmp)]
^ S32(crc)