int main(int argc, char *argv[]) { int infd; char *buf; int len, r; if (argc != 2) { printf("valid param num.\n"); exit(0); } else { infd = open((const char *)argv[1], O_RDONLY, 0); if (infd < 0) { printf("invalid input file. exit.\n"); exit(0); } len = lseek(infd, 0, SEEK_END); } buf = mmap(0, len, PROT_READ, MAP_SHARED, infd, 0); #if 1 r = crc32(buf, len); printf("reg2:0x%8x\n", r); #else char r_buf[8] = {1, 0, 0, 0, 0xdc, 0x6d, 0x9a, 0xb7}; r = crc32_raw(r_buf, sizeof(r_buf)); printf("reg2:0x%8x\n", r); #endif close(infd); return 0; }
static int32_t cdce_m_crc32_cb(void *arg, void *src, uint32_t count) { uint32_t *p_crc = arg; *p_crc = crc32_raw(src, count, *p_crc); return (0); }