1 ///////////////////////////////////////////////////////////////////////////////
3 /// \file crc32_small.c
4 /// \brief CRC32 calculation (size-optimized)
6 // This code has been put into the public domain.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 ///////////////////////////////////////////////////////////////////////////////
17 uint32_t lzma_crc32_table[1][256];
23 static const uint32_t poly32 = UINT32_C(0xEDB88320);
25 for (size_t b = 0; b < 256; ++b) {
27 for (size_t i = 0; i < 8; ++i) {
29 r = (r >> 1) ^ poly32;
34 lzma_crc32_table[0][b] = r;
41 extern LZMA_API(uint32_t)
42 lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
44 mythread_once(crc32_init);
49 crc = lzma_crc32_table[0][*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);