2 * CRC64 using the polynomial from ECMA-182
4 * This file is similar to xz_crc32.c. See the comments there.
6 * Authors: Lasse Collin <lasse.collin@tukaani.org>
7 * Igor Pavlov <http://7-zip.org/>
9 * This file has been put into the public domain.
10 * You can do whatever you want with this file.
13 #include "xz_private.h"
15 #ifndef STATIC_RW_DATA
16 # define STATIC_RW_DATA static
19 STATIC_RW_DATA
uint64_t xz_crc64_table
[256];
21 XZ_EXTERN
void xz_crc64_init(void)
23 const uint64_t poly
= 0xC96C5795D7870F42;
29 for (i
= 0; i
< 256; ++i
) {
31 for (j
= 0; j
< 8; ++j
)
32 r
= (r
>> 1) ^ (poly
& ~((r
& 1) - 1));
34 xz_crc64_table
[i
] = r
;
40 XZ_EXTERN
uint64_t xz_crc64(const uint8_t *buf
, size_t size
, uint64_t crc
)
45 crc
= xz_crc64_table
[*buf
++ ^ (crc
& 0xFF)] ^ (crc
>> 8);