WARNING: Completely untested on big endian architecture. Possibly broken. */
| 214 | |
| 215 | /* WARNING: Completely untested on big endian architecture. Possibly broken. */ |
| 216 | uint16_t crcspeed16big(uint16_t big_table[8][256], uint16_t crc_in, void *buf, |
| 217 | size_t len) { |
| 218 | unsigned char *next = buf; |
| 219 | uint64_t crc = crc_in; |
| 220 | |
| 221 | crc = rev8(crc); |
| 222 | while (len && ((uintptr_t)next & 7) != 0) { |
| 223 | crc = big_table[0][((crc >> (56 - 8)) ^ *next++) & 0xff] ^ (crc >> 8); |
| 224 | len--; |
| 225 | } |
| 226 | |
| 227 | while (len >= 8) { |
| 228 | uint64_t n = *(uint64_t *)next; |
| 229 | crc = big_table[0][(n & 0xff) ^ ((crc >> (56 - 8)) & 0xff)] ^ |
| 230 | big_table[1][((n >> 8) & 0xff) ^ (crc & 0xff)] ^ |
| 231 | big_table[2][(n >> 16) & 0xff] ^ |
| 232 | big_table[3][(n >> 24) & 0xff] ^ |
| 233 | big_table[4][(n >> 32) & 0xff] ^ |
| 234 | big_table[5][(n >> 40) & 0xff] ^ |
| 235 | big_table[6][(n >> 48) & 0xff] ^ |
| 236 | big_table[7][n >> 56]; |
| 237 | next += 8; |
| 238 | len -= 8; |
| 239 | } |
| 240 | |
| 241 | while (len) { |
| 242 | crc = big_table[0][((crc >> (56 - 8)) ^ *next++) & 0xff] ^ (crc >> 8); |
| 243 | len--; |
| 244 | } |
| 245 | |
| 246 | return rev8(crc); |
| 247 | } |
| 248 | |
| 249 | /* Return the CRC of buf[0..len-1] with initial crc, processing eight bytes |
| 250 | at a time using passed-in lookup table. |
no test coverage detected