OLD | NEW |
1 /* CRC32 implementation by Gary S. Brown. See license claim below. */ | 1 /* CRC32 implementation by Gary S. Brown. See license claim below. */ |
2 | 2 |
3 /* ============================================================= */ | 3 /* ============================================================= */ |
4 /* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or */ | 4 /* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or */ |
5 /* code or tables extracted from it, as desired without restriction. */ | 5 /* code or tables extracted from it, as desired without restriction. */ |
6 /* */ | 6 /* */ |
7 /* First, the polynomial itself and its table of feedback terms. The */ | 7 /* First, the polynomial itself and its table of feedback terms. The */ |
8 /* polynomial is */ | 8 /* polynomial is */ |
9 /* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */ | 9 /* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */ |
10 /* */ | 10 /* */ |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 /* Returns a 32-bit CRC of the contents of the buffer. */ | 100 /* Returns a 32-bit CRC of the contents of the buffer. */ |
101 uint32_t Crc32(const void *buffer, uint32_t len) { | 101 uint32_t Crc32(const void *buffer, uint32_t len) { |
102 uint8_t *byte = (uint8_t*)buffer; | 102 uint8_t *byte = (uint8_t*)buffer; |
103 uint32_t i; | 103 uint32_t i; |
104 uint32_t value = ~0U; | 104 uint32_t value = ~0U; |
105 | 105 |
106 for (i = 0; i < len; ++i) | 106 for (i = 0; i < len; ++i) |
107 value = crc32_tab[(value ^ byte[i]) & 0xff] ^ (value >> 8); | 107 value = crc32_tab[(value ^ byte[i]) & 0xff] ^ (value >> 8); |
108 return value ^ ~0U; | 108 return value ^ ~0U; |
109 } | 109 } |
OLD | NEW |