MCPcopy Create free account
hub / github.com/F-Stack/f-stack / crcspeed16big

Function crcspeed16big

app/redis-6.2.6/src/crcspeed.c:216–247  ·  view source on GitHub ↗

WARNING: Completely untested on big endian architecture. Possibly broken. */

Source from the content-addressed store, hash-verified

214
215/* WARNING: Completely untested on big endian architecture. Possibly broken. */
216uint16_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.

Callers 1

crcspeed16nativeFunction · 0.85

Calls 1

rev8Function · 0.85

Tested by

no test coverage detected