src/slz.c
/* This version computes the crc32 of <buf> over <len> bytes, doing most of it
 * in 32-bit chunks.
 */
This version computes the crc32 of  over  bytes, doing most of it
in 32-bit chunks.
This version computes the crc32 of over bytes doing most of it in 32 - bit chunks .
uint32_t slz_crc32_by4(uint32_t crc, const unsigned char *buf, int len)
{
	const unsigned char *end = buf + len;
	while (buf <= end - 16) {
#ifdef UNALIGNED_LE_OK
		crc ^= *(uint32_t *)buf;
		crc = crc32_fast[3][(crc >>  0) & 0xff] ^
		      crc32_fast[2][(crc >>  8) & 0xff] ^
		      crc32_fast[1][(crc >> 16) & 0xff] ^
		      crc32_fast[0][(crc >> 24) & 0xff];
		crc ^= *(uint32_t *)(buf + 4);
		crc = crc32_fast[3][(crc >>  0) & 0xff] ^
		      crc32_fast[2][(crc >>  8) & 0xff] ^
		      crc32_fast[1][(crc >> 16) & 0xff] ^
		      crc32_fast[0][(crc >> 24) & 0xff];
		crc ^= *(uint32_t *)(buf + 8);
		crc = crc32_fast[3][(crc >>  0) & 0xff] ^
		      crc32_fast[2][(crc >>  8) & 0xff] ^
		      crc32_fast[1][(crc >> 16) & 0xff] ^
		      crc32_fast[0][(crc >> 24) & 0xff];
		crc ^= *(uint32_t *)(buf + 12);
		crc = crc32_fast[3][(crc >>  0) & 0xff] ^
		      crc32_fast[2][(crc >>  8) & 0xff] ^
		      crc32_fast[1][(crc >> 16) & 0xff] ^
		      crc32_fast[0][(crc >> 24) & 0xff];
#else
		crc = crc32_fast[3][(buf[0] ^ (crc >>  0)) & 0xff] ^
		      crc32_fast[2][(buf[1] ^ (crc >>  8)) & 0xff] ^
		      crc32_fast[1][(buf[2] ^ (crc >> 16)) & 0xff] ^
		      crc32_fast[0][(buf[3] ^ (crc >> 24)) & 0xff];
		crc = crc32_fast[3][(buf[4] ^ (crc >>  0)) & 0xff] ^
		      crc32_fast[2][(buf[5] ^ (crc >>  8)) & 0xff] ^
		      crc32_fast[1][(buf[6] ^ (crc >> 16)) & 0xff] ^
		      crc32_fast[0][(buf[7] ^ (crc >> 24)) & 0xff];
		crc = crc32_fast[3][(buf[8] ^ (crc >>  0)) & 0xff] ^
		      crc32_fast[2][(buf[9] ^ (crc >>  8)) & 0xff] ^
		      crc32_fast[1][(buf[10] ^ (crc >> 16)) & 0xff] ^
		      crc32_fast[0][(buf[11] ^ (crc >> 24)) & 0xff];
		crc = crc32_fast[3][(buf[12] ^ (crc >>  0)) & 0xff] ^
		      crc32_fast[2][(buf[13] ^ (crc >>  8)) & 0xff] ^
		      crc32_fast[1][(buf[14] ^ (crc >> 16)) & 0xff] ^
		      crc32_fast[0][(buf[15] ^ (crc >> 24)) & 0xff];
#endif
		buf += 16;
	}
	while (buf <= end - 4) {
#ifdef UNALIGNED_LE_OK
		crc ^= *(uint32_t *)buf;
		crc = crc32_fast[3][(crc >>  0) & 0xff] ^
		      crc32_fast[2][(crc >>  8) & 0xff] ^
		      crc32_fast[1][(crc >> 16) & 0xff] ^
		      crc32_fast[0][(crc >> 24) & 0xff];
#else
		crc = crc32_fast[3][(buf[0] ^ (crc >>  0)) & 0xff] ^
		      crc32_fast[2][(buf[1] ^ (crc >>  8)) & 0xff] ^
		      crc32_fast[1][(buf[2] ^ (crc >> 16)) & 0xff] ^
		      crc32_fast[0][(buf[3] ^ (crc >> 24)) & 0xff];
#endif
		buf += 4;
	}
	while (buf < end)
		crc = crc32_fast[0][(crc ^ *buf++) & 0xff] ^ (crc >> 8);
	return crc;
}
uint32_t slz_crc32_by4 ( uint32_t crc , const unsigned char * buf , int len ) { const unsigned char * end = buf + len ; while ( buf <= end - 16 ) { #ifdef UNALIGNED_LE_OK crc ^= * ( uint32_t * ) buf ; crc = crc32_fast [ 3 ] [ ( crc >> 0 ) & 0xff ] ^ crc32_fast [ 2 ] [ ( crc >> 8 ) & 0xff ] ^ crc32_fast [ 1 ] [ ( crc >> 16 ) & 0xff ] ^ crc32_fast [ 0 ] [ ( crc >> 24 ) & 0xff ] ; crc ^= * ( uint32_t * ) ( buf + 4 ) ; crc = crc32_fast [ 3 ] [ ( crc >> 0 ) & 0xff ] ^ crc32_fast [ 2 ] [ ( crc >> 8 ) & 0xff ] ^ crc32_fast [ 1 ] [ ( crc >> 16 ) & 0xff ] ^ crc32_fast [ 0 ] [ ( crc >> 24 ) & 0xff ] ; crc ^= * ( uint32_t * ) ( buf + 8 ) ; crc = crc32_fast [ 3 ] [ ( crc >> 0 ) & 0xff ] ^ crc32_fast [ 2 ] [ ( crc >> 8 ) & 0xff ] ^ crc32_fast [ 1 ] [ ( crc >> 16 ) & 0xff ] ^ crc32_fast [ 0 ] [ ( crc >> 24 ) & 0xff ] ; crc ^= * ( uint32_t * ) ( buf + 12 ) ; crc = crc32_fast [ 3 ] [ ( crc >> 0 ) & 0xff ] ^ crc32_fast [ 2 ] [ ( crc >> 8 ) & 0xff ] ^ crc32_fast [ 1 ] [ ( crc >> 16 ) & 0xff ] ^ crc32_fast [ 0 ] [ ( crc >> 24 ) & 0xff ] ; #else crc = crc32_fast [ 3 ] [ ( buf [ 0 ] ^ ( crc >> 0 ) ) & 0xff ] ^ crc32_fast [ 2 ] [ ( buf [ 1 ] ^ ( crc >> 8 ) ) & 0xff ] ^ crc32_fast [ 1 ] [ ( buf [ 2 ] ^ ( crc >> 16 ) ) & 0xff ] ^ crc32_fast [ 0 ] [ ( buf [ 3 ] ^ ( crc >> 24 ) ) & 0xff ] ; crc = crc32_fast [ 3 ] [ ( buf [ 4 ] ^ ( crc >> 0 ) ) & 0xff ] ^ crc32_fast [ 2 ] [ ( buf [ 5 ] ^ ( crc >> 8 ) ) & 0xff ] ^ crc32_fast [ 1 ] [ ( buf [ 6 ] ^ ( crc >> 16 ) ) & 0xff ] ^ crc32_fast [ 0 ] [ ( buf [ 7 ] ^ ( crc >> 24 ) ) & 0xff ] ; crc = crc32_fast [ 3 ] [ ( buf [ 8 ] ^ ( crc >> 0 ) ) & 0xff ] ^ crc32_fast [ 2 ] [ ( buf [ 9 ] ^ ( crc >> 8 ) ) & 0xff ] ^ crc32_fast [ 1 ] [ ( buf [ 10 ] ^ ( crc >> 16 ) ) & 0xff ] ^ crc32_fast [ 0 ] [ ( buf [ 11 ] ^ ( crc >> 24 ) ) & 0xff ] ; crc = crc32_fast [ 3 ] [ ( buf [ 12 ] ^ ( crc >> 0 ) ) & 0xff ] ^ crc32_fast [ 2 ] [ ( buf [ 13 ] ^ ( crc >> 8 ) ) & 0xff ] ^ crc32_fast [ 1 ] [ ( buf [ 14 ] ^ ( crc >> 16 ) ) & 0xff ] ^ crc32_fast [ 0 ] [ ( buf [ 15 ] ^ ( crc >> 24 ) ) & 0xff ] ; #endif buf += 16 ; } while ( buf <= end - 4 ) { #ifdef UNALIGNED_LE_OK crc ^= * ( uint32_t * ) buf ; crc = crc32_fast [ 3 ] [ ( crc >> 0 ) & 0xff ] ^ crc32_fast [ 2 ] [ ( crc >> 8 ) & 0xff ] ^ crc32_fast [ 1 ] [ ( crc >> 16 ) & 0xff ] ^ crc32_fast [ 0 ] [ ( crc >> 24 ) & 0xff ] ; #else crc = crc32_fast [ 3 ] [ ( buf [ 0 ] ^ ( crc >> 0 ) ) & 0xff ] ^ crc32_fast [ 2 ] [ ( buf [ 1 ] ^ ( crc >> 8 ) ) & 0xff ] ^ crc32_fast [ 1 ] [ ( buf [ 2 ] ^ ( crc >> 16 ) ) & 0xff ] ^ crc32_fast [ 0 ] [ ( buf [ 3 ] ^ ( crc >> 24 ) ) & 0xff ] ; #endif buf += 4 ; } while ( buf < end ) crc = crc32_fast [ 0 ] [ ( crc ^ * buf ++ ) & 0xff ] ^ ( crc >> 8 ) ; return crc ; }
This version computes the crc32 of <buf> over <len> bytes, doing most of it
 in 32-bit chunks.
This version computes the crc32 of <buf > over <len > bytes doing most of it in 32 - bit chunks .