1
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
// vim: expandtab:ts=8:sw=4:softtabstop=4:
3
///////////////////////////////////////////////////////////////////////////////
5
/// \file crc32_small.c
6
/// \brief CRC32 calculation (size-optimized)
8
// Author: Lasse Collin
10
// This file has been put into the public domain.
11
// You can do whatever you want with this file.
13
///////////////////////////////////////////////////////////////////////////////
18
uint32_t lzma_crc32_table[1][256];
24
static const uint32_t poly32 = UINT32_C(0xEDB88320);
26
for (size_t b = 0; b < 256; ++b) {
28
for (size_t i = 0; i < 8; ++i) {
30
r = (r >> 1) ^ poly32;
35
lzma_crc32_table[0][b] = r;
45
mythread_once(crc32_init);
50
extern LZMA_API(uint32_t)
51
lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
58
crc = lzma_crc32_table[0][*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);