/* * Steps through buffer one byte at at time, calculates reflected * crc using table. */ uint32_t crc32c_intel(unsigned char const *data, unsigned long length) { unsigned int iquotient = length / SCALE_F; unsigned int iremainder = length % SCALE_F; #if BITS_PER_LONG == 64 uint64_t *ptmp = (uint64_t *) data; #else uint32_t *ptmp = (uint32_t *) data; #endif uint32_t crc = ~0; while (iquotient--) { __asm__ __volatile__( ".byte 0xf2, " REX_PRE "0xf, 0x38, 0xf1, 0xf1;" :"=S"(crc) :"0"(crc), "c"(*ptmp) ); ptmp++; } if (iremainder) crc = crc32c_intel_le_hw_byte(crc, (unsigned char *)ptmp, iremainder); return crc; }
static u32 __pure crc32c_intel_le_hw(u32 crc, unsigned char const *p, size_t len) { unsigned int iquotient = len / SCALE_F; unsigned int iremainder = len % SCALE_F; unsigned long *ptmp = (unsigned long *)p; while (iquotient--) { __asm__ __volatile__( ".byte 0xf2, " REX_PRE "0xf, 0x38, 0xf1, 0xf1;" :"=S"(crc) :"0"(crc), "c"(*ptmp) ); ptmp++; } if (iremainder) crc = crc32c_intel_le_hw_byte(crc, (unsigned char *)ptmp, iremainder); return crc; }