1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief CRC64 table initialization
6 // This code is based on various public domain sources.
7 // This code has been put into the public domain.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 ///////////////////////////////////////////////////////////////////////////////
19 #ifdef WORDS_BIGENDIAN
20 # include "check_byteswap.h"
24 uint64_t lzma_crc64_table[4][256];
30 static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);
32 for (size_t s = 0; s < 4; ++s) {
33 for (size_t b = 0; b < 256; ++b) {
34 uint64_t r = s == 0 ? b : lzma_crc64_table[s - 1][b];
36 for (size_t i = 0; i < 8; ++i) {
38 r = (r >> 1) ^ poly64;
43 lzma_crc64_table[s][b] = r;
47 #ifdef WORDS_BIGENDIAN
48 for (size_t s = 0; s < 4; ++s)
49 for (size_t b = 0; b < 256; ++b)
50 lzma_crc64_table[s][b]
51 = bswap_64(lzma_crc64_table[s][b]);