Avoid these macros

This commit is contained in:
twinaphex 2016-09-18 19:00:39 +02:00
parent 64ea2256e5
commit 7da0c4fa46

View File

@ -78,29 +78,22 @@ static const uint32_t crc32_table[256] = {
0x2d02ef8dL
};
#undef DO1_CRC32
#undef DO2_CRC32
#undef DO4_CRC32
#undef DO8_CRC32
#define DO1_CRC32(buf) crc = crc32_table[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
#define DO2_CRC32(buf) DO1_CRC32(buf); DO1_CRC32(buf);
#define DO4_CRC32(buf) DO2_CRC32(buf); DO2_CRC32(buf);
#define DO8_CRC32(buf) DO4_CRC32(buf); DO4_CRC32(buf);
uint32_t encoding_crc32(uint32_t crc, const uint8_t *buf, size_t len)
{
crc = crc ^ 0xffffffff;
while (len >= 8)
{
DO8_CRC32(buf);
unsigned j;
for (j = 0; j < 8; j++)
crc = crc32_table[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
len -= 8;
}
if (len)
{
do
{
DO1_CRC32(buf);
crc = crc32_table[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
} while (--len);
}