18static std::vector<unsigned long> gen_crc_table() {
20 static const unsigned long POLYNOMIAL = 0x04c11db7UL;
22 for (
unsigned long i = 0; i < 256; ++i ) {
23 unsigned long crc = i << 24;
24 for (
int j = 0; j < 8; j++ ) {
25 if ( crc & 0x80000000UL ) {
26 crc = ( ( crc << 1 ) ^ POLYNOMIAL ) & 0xffffffffUL;
28 crc = ( crc << 1 ) & 0xffffffffUL;
36unsigned long crc32ul(
const std::string & s) {
37 static const std::vector<unsigned long>
crc_table = gen_crc_table();
38 unsigned long crc = 0;
39 unsigned long end = s.length();
40 for (
unsigned long j = 0; j != end; ++j) {
41 int i = ( (int) ( crc >> 24) ^ s[j] ) & 0xff;
42 crc = ( ( crc << 8 ) ^
crc_table[i] ) & 0xffffffffUL;
local const z_crc_t FAR crc_table[]
unsigned long crc32ul(const std::string &s)