Естественно ...
| Код | template < std::size_t Bits > inline void crc_basic<Bits>::process_bit ( bool bit ) { value_type const high_bit_mask = masking_type::high_bit;
// compare the new bit with the remainder's highest rem_ ^= ( bit ? high_bit_mask : 0u );
// a full polynominal division step is done when the highest bit is one bool const do_poly_div = static_cast<bool>( rem_ & high_bit_mask );
// shift out the highest bit rem_ <<= 1;
// carry out the division, if needed if ( do_poly_div ) { rem_ ^= poly_; } }
template < std::size_t Bits > void crc_basic<Bits>::process_bits ( unsigned char bits, std::size_t bit_count ) { // ignore the bits above the ones we want bits <<= CHAR_BIT - bit_count;
// compute the CRC for each bit, starting with the upper ones unsigned char const high_bit_mask = 1u << ( CHAR_BIT - 1u ); for ( std::size_t i = bit_count ; i > 0u ; --i, bits <<= 1u ) { process_bit( static_cast<bool>(bits & high_bit_mask) ); } }
template < std::size_t Bits > inline void crc_basic<Bits>::process_byte ( unsigned char byte ) { process_bits( (rft_in_ ? detail::reflector<CHAR_BIT>::reflect(byte) : byte), CHAR_BIT ); }
|
Против
| Код | unsigned long ZEXPORT crc32(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; uInt len; { if (buf == Z_NULL) return 0UL;
#ifdef DYNAMIC_CRC_TABLE if (crc_table_empty) make_crc_table(); #endif /* DYNAMIC_CRC_TABLE */
#ifdef BYFOUR if (sizeof(void *) == sizeof(ptrdiff_t)) { u4 endian;
endian = 1; if (*((unsigned char *)(&endian))) return crc32_little(crc, buf, len); else return crc32_big(crc, buf, len); } #endif /* BYFOUR */ crc = crc ^ 0xffffffffUL; while (len >= 8) { DO8; len -= 8; } if (len) do { DO1; } while (--len); return crc ^ 0xffffffffUL; }
|
|