crc: reformat using new code style

Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>
This commit is contained in:
Marcel Cornu 2024-04-19 17:08:33 +01:00 committed by Pablo de Lara
parent 07bca509e7
commit 671e67b62d
20 changed files with 1995 additions and 2534 deletions

View File

@ -30,12 +30,14 @@
#include "crc64.h" #include "crc64.h"
#include <stdint.h> #include <stdint.h>
uint64_t crc64_rocksoft_refl(uint64_t seed, const uint8_t * buf, uint64_t len) uint64_t
crc64_rocksoft_refl(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc64_rocksoft_refl_base(seed, buf, len); return crc64_rocksoft_refl_base(seed, buf, len);
} }
uint64_t crc64_rocksoft_norm(uint64_t seed, const uint8_t * buf, uint64_t len) uint64_t
crc64_rocksoft_norm(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc64_rocksoft_norm_base(seed, buf, len); return crc64_rocksoft_norm_base(seed, buf, len);
} }

View File

@ -39,7 +39,6 @@ DEFINE_INTERFACE_DISPATCHER(crc16_t10dif)
return PROVIDER_INFO(crc16_t10dif_pmull); return PROVIDER_INFO(crc16_t10dif_pmull);
#endif #endif
return PROVIDER_BASIC(crc16_t10dif); return PROVIDER_BASIC(crc16_t10dif);
} }
DEFINE_INTERFACE_DISPATCHER(crc16_t10dif_copy) DEFINE_INTERFACE_DISPATCHER(crc16_t10dif_copy)
@ -53,7 +52,6 @@ DEFINE_INTERFACE_DISPATCHER(crc16_t10dif_copy)
return PROVIDER_INFO(crc16_t10dif_copy_pmull); return PROVIDER_INFO(crc16_t10dif_copy_pmull);
#endif #endif
return PROVIDER_BASIC(crc16_t10dif_copy); return PROVIDER_BASIC(crc16_t10dif_copy);
} }
DEFINE_INTERFACE_DISPATCHER(crc32_ieee) DEFINE_INTERFACE_DISPATCHER(crc32_ieee)
@ -68,7 +66,6 @@ DEFINE_INTERFACE_DISPATCHER(crc32_ieee)
return PROVIDER_INFO(crc32_ieee_norm_pmull); return PROVIDER_INFO(crc32_ieee_norm_pmull);
#endif #endif
return PROVIDER_BASIC(crc32_ieee); return PROVIDER_BASIC(crc32_ieee);
} }
DEFINE_INTERFACE_DISPATCHER(crc32_iscsi) DEFINE_INTERFACE_DISPATCHER(crc32_iscsi)
@ -97,7 +94,6 @@ DEFINE_INTERFACE_DISPATCHER(crc32_iscsi)
return PROVIDER_INFO(crc32_iscsi_refl_pmull); return PROVIDER_INFO(crc32_iscsi_refl_pmull);
#endif #endif
return PROVIDER_BASIC(crc32_iscsi); return PROVIDER_BASIC(crc32_iscsi);
} }
DEFINE_INTERFACE_DISPATCHER(crc32_gzip_refl) DEFINE_INTERFACE_DISPATCHER(crc32_gzip_refl)
@ -126,7 +122,6 @@ DEFINE_INTERFACE_DISPATCHER(crc32_gzip_refl)
return PROVIDER_INFO(crc32_gzip_refl_pmull); return PROVIDER_INFO(crc32_gzip_refl_pmull);
#endif #endif
return PROVIDER_BASIC(crc32_gzip_refl); return PROVIDER_BASIC(crc32_gzip_refl);
} }
DEFINE_INTERFACE_DISPATCHER(crc64_ecma_refl) DEFINE_INTERFACE_DISPATCHER(crc64_ecma_refl)
@ -141,7 +136,6 @@ DEFINE_INTERFACE_DISPATCHER(crc64_ecma_refl)
return PROVIDER_INFO(crc64_ecma_refl_pmull); return PROVIDER_INFO(crc64_ecma_refl_pmull);
#endif #endif
return PROVIDER_BASIC(crc64_ecma_refl); return PROVIDER_BASIC(crc64_ecma_refl);
} }
DEFINE_INTERFACE_DISPATCHER(crc64_ecma_norm) DEFINE_INTERFACE_DISPATCHER(crc64_ecma_norm)
@ -155,7 +149,6 @@ DEFINE_INTERFACE_DISPATCHER(crc64_ecma_norm)
return PROVIDER_INFO(crc64_ecma_norm_pmull); return PROVIDER_INFO(crc64_ecma_norm_pmull);
#endif #endif
return PROVIDER_BASIC(crc64_ecma_norm); return PROVIDER_BASIC(crc64_ecma_norm);
} }
DEFINE_INTERFACE_DISPATCHER(crc64_iso_refl) DEFINE_INTERFACE_DISPATCHER(crc64_iso_refl)
@ -169,7 +162,6 @@ DEFINE_INTERFACE_DISPATCHER(crc64_iso_refl)
return PROVIDER_INFO(crc64_iso_refl_pmull); return PROVIDER_INFO(crc64_iso_refl_pmull);
#endif #endif
return PROVIDER_BASIC(crc64_iso_refl); return PROVIDER_BASIC(crc64_iso_refl);
} }
DEFINE_INTERFACE_DISPATCHER(crc64_iso_norm) DEFINE_INTERFACE_DISPATCHER(crc64_iso_norm)
@ -183,7 +175,6 @@ DEFINE_INTERFACE_DISPATCHER(crc64_iso_norm)
return PROVIDER_INFO(crc64_iso_norm_pmull); return PROVIDER_INFO(crc64_iso_norm_pmull);
#endif #endif
return PROVIDER_BASIC(crc64_iso_norm); return PROVIDER_BASIC(crc64_iso_norm);
} }
DEFINE_INTERFACE_DISPATCHER(crc64_jones_refl) DEFINE_INTERFACE_DISPATCHER(crc64_jones_refl)
@ -197,7 +188,6 @@ DEFINE_INTERFACE_DISPATCHER(crc64_jones_refl)
return PROVIDER_INFO(crc64_jones_refl_pmull); return PROVIDER_INFO(crc64_jones_refl_pmull);
#endif #endif
return PROVIDER_BASIC(crc64_jones_refl); return PROVIDER_BASIC(crc64_jones_refl);
} }
DEFINE_INTERFACE_DISPATCHER(crc64_jones_norm) DEFINE_INTERFACE_DISPATCHER(crc64_jones_norm)
@ -211,5 +201,4 @@ DEFINE_INTERFACE_DISPATCHER(crc64_jones_norm)
return PROVIDER_INFO(crc64_jones_norm_pmull); return PROVIDER_INFO(crc64_jones_norm_pmull);
#endif #endif
return PROVIDER_BASIC(crc64_jones_norm); return PROVIDER_BASIC(crc64_jones_norm);
} }

View File

@ -35,26 +35,27 @@
#include "test.h" #include "test.h"
#ifndef GT_L3_CACHE #ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ #define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif #endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM) #if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset // Cached test, loop many times over small dataset
# define TEST_LEN 8*1024 #define TEST_LEN 8 * 1024
# define TEST_TYPE_STR "_warm" #define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST) #elif defined(COLD_TEST)
// Uncached test. Pull from large mem base. // Uncached test. Pull from large mem base.
# define TEST_LEN (2 * GT_L3_CACHE) #define TEST_LEN (2 * GT_L3_CACHE)
# define TEST_TYPE_STR "_cold" #define TEST_TYPE_STR "_cold"
#endif #endif
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
#define TEST_MEM TEST_LEN #define TEST_MEM TEST_LEN
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
void *src, *dst; void *src, *dst;
uint16_t crc; uint16_t crc;
@ -75,10 +76,9 @@ int main(int argc, char *argv[])
fflush(0); fflush(0);
memset(src, 0, TEST_LEN); memset(src, 0, TEST_LEN);
BENCHMARK(&start, BENCHMARK_TIME, crc = BENCHMARK(&start, BENCHMARK_TIME, crc = crc16_t10dif_copy(TEST_SEED, dst, src, TEST_LEN));
crc16_t10dif_copy(TEST_SEED, dst, src, TEST_LEN));
printf("crc16_t10dif_copy" TEST_TYPE_STR ": "); printf("crc16_t10dif_copy" TEST_TYPE_STR ": ");
perf_print(start, (long long)TEST_LEN); perf_print(start, (long long) TEST_LEN);
printf("finish 0x%x\n", crc); printf("finish 0x%x\n", crc);
return 0; return 0;

View File

@ -37,10 +37,10 @@
#include "test.h" #include "test.h"
#ifndef RANDOMS #ifndef RANDOMS
# define RANDOMS 20 #define RANDOMS 20
#endif #endif
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
#define MAX_BUF 2345 #define MAX_BUF 2345
@ -51,16 +51,19 @@ typedef uint16_t u16;
typedef uint8_t u8; typedef uint8_t u8;
// bitwise crc version // bitwise crc version
uint16_t crc16_t10dif_copy_ref(uint16_t seed, uint8_t * dst, uint8_t * src, uint64_t len); uint16_t
crc16_t10dif_copy_ref(uint16_t seed, uint8_t *dst, uint8_t *src, uint64_t len);
void rand_buffer(unsigned char *buf, long buffer_size) void
rand_buffer(unsigned char *buf, long buffer_size)
{ {
long i; long i;
for (i = 0; i < buffer_size; i++) for (i = 0; i < buffer_size; i++)
buf[i] = rand(); buf[i] = rand();
} }
int memtst(unsigned char *buf, unsigned char c, int len) int
memtst(unsigned char *buf, unsigned char c, int len)
{ {
int i; int i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
@ -70,8 +73,8 @@ int memtst(unsigned char *buf, unsigned char c, int len)
return 0; return 0;
} }
int crc_copy_check(const char *description, u8 * dst, u8 * src, u8 dst_fill_val, int len, int
int tot) crc_copy_check(const char *description, u8 *dst, u8 *src, u8 dst_fill_val, int len, int tot)
{ {
u16 seed; u16 seed;
int rem; int rem;
@ -85,8 +88,8 @@ int crc_copy_check(const char *description, u8 * dst, u8 * src, u8 dst_fill_val,
u16 crc_dut = crc16_t10dif_copy(seed, dst, src, len); u16 crc_dut = crc16_t10dif_copy(seed, dst, src, len);
u16 crc_ref = crc16_t10dif(seed, src, len); u16 crc_ref = crc16_t10dif(seed, src, len);
if (crc_dut != crc_ref) { if (crc_dut != crc_ref) {
printf("%s, crc gen fail: 0x%4x 0x%4x len=%d\n", description, crc_dut, printf("%s, crc gen fail: 0x%4x 0x%4x len=%d\n", description, crc_dut, crc_ref,
crc_ref, len); len);
return 1; return 1;
} else if (memcmp(dst, src, len)) { } else if (memcmp(dst, src, len)) {
printf("%s, copy fail: len=%d\n", description, len); printf("%s, copy fail: len=%d\n", description, len);
@ -112,7 +115,8 @@ int crc_copy_check(const char *description, u8 * dst, u8 * src, u8 dst_fill_val,
return 0; return 0;
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int r = 0; int r = 0;
int i; int i;

View File

@ -37,22 +37,22 @@
#define BLKSIZE (512) #define BLKSIZE (512)
#ifndef GT_L3_CACHE #ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ #define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif #endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM) #if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset // Cached test, loop many times over small dataset
# define NBLOCKS 100 #define NBLOCKS 100
# define TEST_TYPE_STR "_warm" #define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST) #elif defined(COLD_TEST)
// Uncached test. Pull from large mem base. // Uncached test. Pull from large mem base.
# define TEST_LEN (2 * GT_L3_CACHE) #define TEST_LEN (2 * GT_L3_CACHE)
# define NBLOCKS (TEST_LEN / BLKSIZE) #define NBLOCKS (TEST_LEN / BLKSIZE)
# define TEST_TYPE_STR "_cold" #define TEST_TYPE_STR "_cold"
#endif #endif
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
struct blk { struct blk {
@ -66,21 +66,21 @@ struct blk_ext {
uint16_t crc; uint16_t crc;
}; };
static void crc16_t10dif_copy_perf(struct blk *blks, struct blk *blkp, static void
struct blk_ext *blks_ext, struct blk_ext *blkp_ext, crc16_t10dif_copy_perf(struct blk *blks, struct blk *blkp, struct blk_ext *blks_ext,
uint16_t * crc) struct blk_ext *blkp_ext, uint16_t *crc)
{ {
int i; int i;
for (i = 0, blkp = blks, blkp_ext = blks_ext; i < NBLOCKS; i++) { for (i = 0, blkp = blks, blkp_ext = blks_ext; i < NBLOCKS; i++) {
*crc = crc16_t10dif_copy(TEST_SEED, blkp_ext->data, blkp->data, *crc = crc16_t10dif_copy(TEST_SEED, blkp_ext->data, blkp->data, sizeof(blks->data));
sizeof(blks->data));
blkp_ext->crc = *crc; blkp_ext->crc = *crc;
blkp++; blkp++;
blkp_ext++; blkp_ext++;
} }
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
uint16_t crc; uint16_t crc;
struct blk *blks = NULL, *blkp = NULL; struct blk *blks = NULL, *blkp = NULL;
@ -89,18 +89,17 @@ int main(int argc, char *argv[])
printf("crc16_t10dif_streaming_insert_perf:\n"); printf("crc16_t10dif_streaming_insert_perf:\n");
if (posix_memalign((void *)&blks, 1024, NBLOCKS * sizeof(*blks))) { if (posix_memalign((void *) &blks, 1024, NBLOCKS * sizeof(*blks))) {
printf("alloc error: Fail"); printf("alloc error: Fail");
return -1; return -1;
} }
if (posix_memalign((void *)&blks_ext, 1024, NBLOCKS * sizeof(*blks_ext))) { if (posix_memalign((void *) &blks_ext, 1024, NBLOCKS * sizeof(*blks_ext))) {
printf("alloc error: Fail"); printf("alloc error: Fail");
return -1; return -1;
} }
printf(" size blk: %zu, blk_ext: %zu, blk data: %zu, stream: %zu\n", printf(" size blk: %zu, blk_ext: %zu, blk data: %zu, stream: %zu\n", sizeof(*blks),
sizeof(*blks), sizeof(*blks_ext), sizeof(blks->data), sizeof(*blks_ext), sizeof(blks->data), NBLOCKS * sizeof(blks->data));
NBLOCKS * sizeof(blks->data));
memset(blks, 0xe5, NBLOCKS * sizeof(*blks)); memset(blks, 0xe5, NBLOCKS * sizeof(*blks));
memset(blks_ext, 0xe5, NBLOCKS * sizeof(*blks_ext)); memset(blks_ext, 0xe5, NBLOCKS * sizeof(*blks_ext));
@ -112,7 +111,7 @@ int main(int argc, char *argv[])
crc16_t10dif_copy_perf(blks, blkp, blks_ext, blkp_ext, &crc)); crc16_t10dif_copy_perf(blks, blkp, blks_ext, blkp_ext, &crc));
printf("crc16_t10pi_op_copy_insert" TEST_TYPE_STR ": "); printf("crc16_t10pi_op_copy_insert" TEST_TYPE_STR ": ");
perf_print(start, (long long)sizeof(blks->data) * NBLOCKS); perf_print(start, (long long) sizeof(blks->data) * NBLOCKS);
printf("finish 0x%x\n", crc); printf("finish 0x%x\n", crc);
return 0; return 0;

View File

@ -35,26 +35,27 @@
#include "test.h" #include "test.h"
#ifndef GT_L3_CACHE #ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ #define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif #endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM) #if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset // Cached test, loop many times over small dataset
# define TEST_LEN 8*1024 #define TEST_LEN 8 * 1024
# define TEST_TYPE_STR "_warm" #define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST) #elif defined(COLD_TEST)
// Uncached test. Pull from large mem base. // Uncached test. Pull from large mem base.
# define TEST_LEN (2 * GT_L3_CACHE) #define TEST_LEN (2 * GT_L3_CACHE)
# define TEST_TYPE_STR "_cold" #define TEST_TYPE_STR "_cold"
#endif #endif
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
#define TEST_MEM TEST_LEN #define TEST_MEM TEST_LEN
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
void *buf; void *buf;
uint16_t crc; uint16_t crc;
@ -73,7 +74,7 @@ int main(int argc, char *argv[])
memset(buf, 0, TEST_LEN); memset(buf, 0, TEST_LEN);
BENCHMARK(&start, BENCHMARK_TIME, crc = crc16_t10dif(TEST_SEED, buf, TEST_LEN)); BENCHMARK(&start, BENCHMARK_TIME, crc = crc16_t10dif(TEST_SEED, buf, TEST_LEN));
printf("crc16_t10dif" TEST_TYPE_STR ": "); printf("crc16_t10dif" TEST_TYPE_STR ": ");
perf_print(start, (long long)TEST_LEN); perf_print(start, (long long) TEST_LEN);
printf("finish 0x%x\n", crc); printf("finish 0x%x\n", crc);
return 0; return 0;

View File

@ -36,7 +36,7 @@
#include "test.h" #include "test.h"
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
#define MAX_BUF 4096 #define MAX_BUF 4096
@ -46,16 +46,19 @@ typedef uint32_t u32;
typedef uint16_t u16; typedef uint16_t u16;
typedef uint8_t u8; typedef uint8_t u8;
uint16_t crc16_t10dif_ref(uint16_t seed, uint8_t * buf, uint64_t len); uint16_t
crc16_t10dif_ref(uint16_t seed, uint8_t *buf, uint64_t len);
void rand_buffer(unsigned char *buf, long buffer_size) void
rand_buffer(unsigned char *buf, long buffer_size)
{ {
long i; long i;
for (i = 0; i < buffer_size; i++) for (i = 0; i < buffer_size; i++)
buf[i] = rand(); buf[i] = rand();
} }
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int fail = 0; int fail = 0;
u32 r = 0; u32 r = 0;
@ -68,7 +71,7 @@ int main(int argc, char *argv[])
printf("alloc error: Fail"); printf("alloc error: Fail");
return -1; return -1;
} }
buf = (unsigned char *)buf_raw; buf = (unsigned char *) buf_raw;
srand(TEST_SEED); srand(TEST_SEED);
@ -112,8 +115,7 @@ int main(int argc, char *argv[])
crc = crc16_t10dif(TEST_SEED, buf, MAX_BUF); crc = crc16_t10dif(TEST_SEED, buf, MAX_BUF);
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail crc rand%3d = 0x%4x 0x%4x 0x%4x\n", i, crc_ref, crc_base, printf("fail crc rand%3d = 0x%4x 0x%4x 0x%4x\n", i, crc_ref, crc_base, crc);
crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else if (i % (TEST_SIZE / 8) == 0) else if (i % (TEST_SIZE / 8) == 0)
@ -123,7 +125,7 @@ int main(int argc, char *argv[])
} }
// Do a few random sizes // Do a few random sizes
buf = (unsigned char *)buf_raw; //reset buf buf = (unsigned char *) buf_raw; // reset buf
r = rand(); r = rand();
for (i = MAX_BUF; i >= 0; i--) { for (i = MAX_BUF; i >= 0; i--) {
@ -132,8 +134,7 @@ int main(int argc, char *argv[])
crc = crc16_t10dif(r, buf, i); crc = crc16_t10dif(r, buf, i);
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail random size%i 0x%8x 0x%8x 0x%8x\n", i, crc_ref, crc_base, printf("fail random size%i 0x%8x 0x%8x 0x%8x\n", i, crc_ref, crc_base, crc);
crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else if (i % (MAX_BUF / 8) == 0) else if (i % (MAX_BUF / 8) == 0)
@ -143,7 +144,7 @@ int main(int argc, char *argv[])
// Try different seeds // Try different seeds
for (s = 0; s < 20; s++) { for (s = 0; s < 20; s++) {
buf = (unsigned char *)buf_raw; //reset buf buf = (unsigned char *) buf_raw; // reset buf
r = rand(); // just to get a new seed r = rand(); // just to get a new seed
rand_buffer(buf, MAX_BUF * TEST_SIZE); // new pseudo-rand data rand_buffer(buf, MAX_BUF * TEST_SIZE); // new pseudo-rand data
@ -170,16 +171,16 @@ int main(int argc, char *argv[])
} }
// Run tests at end of buffer // Run tests at end of buffer
buf = (unsigned char *)buf_raw; //reset buf buf = (unsigned char *) buf_raw; // reset buf
buf = buf + ((MAX_BUF - 1) * TEST_SIZE); //Line up TEST_SIZE from end buf = buf + ((MAX_BUF - 1) * TEST_SIZE); // Line up TEST_SIZE from end
for (i = 0; i < TEST_SIZE; i++) { for (i = 0; i < TEST_SIZE; i++) {
crc_ref = crc16_t10dif_ref(TEST_SEED, buf + i, TEST_SIZE - i); crc_ref = crc16_t10dif_ref(TEST_SEED, buf + i, TEST_SIZE - i);
crc_base = crc16_t10dif_base(TEST_SEED, buf + i, TEST_SIZE - i); crc_base = crc16_t10dif_base(TEST_SEED, buf + i, TEST_SIZE - i);
crc = crc16_t10dif(TEST_SEED, buf + i, TEST_SIZE - i); crc = crc16_t10dif(TEST_SEED, buf + i, TEST_SIZE - i);
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail crc eob rand%3d = 0x%4x 0x%4x 0x%4x\n", i, crc_ref, printf("fail crc eob rand%3d = 0x%4x 0x%4x 0x%4x\n", i, crc_ref, crc_base,
crc_base, crc); crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else else

View File

@ -36,15 +36,15 @@
#include "test.h" #include "test.h"
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
#define MAX_BUF 4096 #define MAX_BUF 4096
#define TEST_SIZE 32 #define TEST_SIZE 32
typedef uint32_t(*crc32_func_t) (uint32_t, const uint8_t *, uint64_t); typedef uint32_t (*crc32_func_t)(uint32_t, const uint8_t *, uint64_t);
typedef uint32_t(*crc32_func_t_base) (uint32_t, uint8_t *, uint64_t); typedef uint32_t (*crc32_func_t_base)(uint32_t, uint8_t *, uint64_t);
typedef uint32_t(*crc32_func_t_ref) (uint32_t, uint8_t *, uint64_t); typedef uint32_t (*crc32_func_t_ref)(uint32_t, uint8_t *, uint64_t);
typedef struct func_case { typedef struct func_case {
char *note; char *note;
@ -53,32 +53,34 @@ typedef struct func_case {
crc32_func_t_ref crc32_ref_call; crc32_func_t_ref crc32_ref_call;
} func_case_t; } func_case_t;
uint32_t crc32_iscsi_wrap(uint32_t seed, const uint8_t * buf, uint64_t len) uint32_t
crc32_iscsi_wrap(uint32_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc32_iscsi((uint8_t *) buf, len, seed); return crc32_iscsi((uint8_t *) buf, len, seed);
} }
uint32_t crc32_iscsi_base_wrap(uint32_t seed, uint8_t * buf, uint64_t len) uint32_t
crc32_iscsi_base_wrap(uint32_t seed, uint8_t *buf, uint64_t len)
{ {
return crc32_iscsi_base(buf, len, seed); return crc32_iscsi_base(buf, len, seed);
} }
uint32_t crc32_iscsi_ref_wrap(uint32_t seed, uint8_t * buf, uint64_t len) uint32_t
crc32_iscsi_ref_wrap(uint32_t seed, uint8_t *buf, uint64_t len)
{ {
return crc32_iscsi_ref(buf, len, seed); return crc32_iscsi_ref(buf, len, seed);
} }
func_case_t test_funcs[] = { func_case_t test_funcs[] = {
{"crc32_ieee", crc32_ieee, crc32_ieee_base, crc32_ieee_ref} { "crc32_ieee", crc32_ieee, crc32_ieee_base, crc32_ieee_ref },
, { "crc32_gzip_refl", crc32_gzip_refl, crc32_gzip_refl_base, crc32_gzip_refl_ref },
{"crc32_gzip_refl", crc32_gzip_refl, crc32_gzip_refl_base, crc32_gzip_refl_ref} { "crc32_iscsi", crc32_iscsi_wrap, crc32_iscsi_base_wrap, crc32_iscsi_ref_wrap }
,
{"crc32_iscsi", crc32_iscsi_wrap, crc32_iscsi_base_wrap, crc32_iscsi_ref_wrap}
}; };
// Generates pseudo-random data // Generates pseudo-random data
void rand_buffer(unsigned char *buf, long buffer_size) void
rand_buffer(unsigned char *buf, long buffer_size)
{ {
long i; long i;
for (i = 0; i < buffer_size; i++) for (i = 0; i < buffer_size; i++)
@ -86,19 +88,25 @@ void rand_buffer(unsigned char *buf, long buffer_size)
} }
// Test cases // Test cases
int zeros_test(func_case_t * test_func); int
zeros_test(func_case_t *test_func);
int simple_pattern_test(func_case_t * test_func); int
simple_pattern_test(func_case_t *test_func);
int seeds_sizes_test(func_case_t * test_func); int
seeds_sizes_test(func_case_t *test_func);
int eob_test(func_case_t * test_func); int
eob_test(func_case_t *test_func);
int update_test(func_case_t * test_func); int
update_test(func_case_t *test_func);
void *buf_alloc = NULL; void *buf_alloc = NULL;
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int fail = 0, fail_case; int fail = 0, fail_case;
int i, ret; int i, ret;
@ -139,13 +147,14 @@ int main(int argc, char *argv[])
} }
// Test of all zeros // Test of all zeros
int zeros_test(func_case_t * test_func) int
zeros_test(func_case_t *test_func)
{ {
uint32_t crc_ref, crc_base, crc; uint32_t crc_ref, crc_base, crc;
int fail = 0; int fail = 0;
unsigned char *buf = NULL; unsigned char *buf = NULL;
buf = (unsigned char *)buf_alloc; buf = (unsigned char *) buf_alloc;
memset(buf, 0, MAX_BUF * 10); memset(buf, 0, MAX_BUF * 10);
crc_ref = test_func->crc32_ref_call(TEST_SEED, buf, MAX_BUF * 10); crc_ref = test_func->crc32_ref_call(TEST_SEED, buf, MAX_BUF * 10);
crc_base = test_func->crc32_base_call(TEST_SEED, buf, MAX_BUF * 10); crc_base = test_func->crc32_base_call(TEST_SEED, buf, MAX_BUF * 10);
@ -166,13 +175,14 @@ int zeros_test(func_case_t * test_func)
} }
// Another simple test pattern // Another simple test pattern
int simple_pattern_test(func_case_t * test_func) int
simple_pattern_test(func_case_t *test_func)
{ {
uint32_t crc_ref, crc_base, crc; uint32_t crc_ref, crc_base, crc;
int fail = 0; int fail = 0;
unsigned char *buf = NULL; unsigned char *buf = NULL;
buf = (unsigned char *)buf_alloc; buf = (unsigned char *) buf_alloc;
memset(buf, 0x8a, MAX_BUF); memset(buf, 0x8a, MAX_BUF);
crc_ref = test_func->crc32_ref_call(TEST_SEED, buf, MAX_BUF); crc_ref = test_func->crc32_ref_call(TEST_SEED, buf, MAX_BUF);
crc_base = test_func->crc32_base_call(TEST_SEED, buf, MAX_BUF); crc_base = test_func->crc32_base_call(TEST_SEED, buf, MAX_BUF);
@ -190,7 +200,8 @@ int simple_pattern_test(func_case_t * test_func)
return fail; return fail;
} }
int seeds_sizes_test(func_case_t * test_func) int
seeds_sizes_test(func_case_t *test_func)
{ {
uint32_t crc_ref, crc_base, crc; uint32_t crc_ref, crc_base, crc;
int fail = 0; int fail = 0;
@ -199,7 +210,7 @@ int seeds_sizes_test(func_case_t * test_func)
unsigned char *buf = NULL; unsigned char *buf = NULL;
// Do a few random tests // Do a few random tests
buf = (unsigned char *)buf_alloc; //reset buf buf = (unsigned char *) buf_alloc; // reset buf
r = rand(); r = rand();
rand_buffer(buf, MAX_BUF * TEST_SIZE); rand_buffer(buf, MAX_BUF * TEST_SIZE);
@ -210,8 +221,7 @@ int seeds_sizes_test(func_case_t * test_func)
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail crc rand%3d = 0x%8x 0x%8x 0x%8x\n", i, crc_ref, crc_base, printf("fail crc rand%3d = 0x%8x 0x%8x 0x%8x\n", i, crc_ref, crc_base, crc);
crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else if (i % (TEST_SIZE / 8) == 0) else if (i % (TEST_SIZE / 8) == 0)
@ -221,7 +231,7 @@ int seeds_sizes_test(func_case_t * test_func)
} }
// Do a few random sizes // Do a few random sizes
buf = (unsigned char *)buf_alloc; //reset buf buf = (unsigned char *) buf_alloc; // reset buf
r = rand(); r = rand();
for (i = MAX_BUF; i >= 0; i--) { for (i = MAX_BUF; i >= 0; i--) {
@ -231,8 +241,7 @@ int seeds_sizes_test(func_case_t * test_func)
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail random size%i 0x%8x 0x%8x 0x%8x\n", i, crc_ref, crc_base, printf("fail random size%i 0x%8x 0x%8x 0x%8x\n", i, crc_ref, crc_base, crc);
crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else if (i % (MAX_BUF / 8) == 0) else if (i % (MAX_BUF / 8) == 0)
@ -242,7 +251,7 @@ int seeds_sizes_test(func_case_t * test_func)
// Try different seeds // Try different seeds
for (s = 0; s < 20; s++) { for (s = 0; s < 20; s++) {
buf = (unsigned char *)buf_alloc; //reset buf buf = (unsigned char *) buf_alloc; // reset buf
r = rand(); // just to get a new seed r = rand(); // just to get a new seed
rand_buffer(buf, MAX_BUF * TEST_SIZE); // new pseudo-rand data rand_buffer(buf, MAX_BUF * TEST_SIZE); // new pseudo-rand data
@ -273,7 +282,8 @@ int seeds_sizes_test(func_case_t * test_func)
} }
// Run tests at end of buffer // Run tests at end of buffer
int eob_test(func_case_t * test_func) int
eob_test(func_case_t *test_func)
{ {
uint32_t crc_ref, crc_base, crc; uint32_t crc_ref, crc_base, crc;
int fail = 0; int fail = 0;
@ -286,8 +296,8 @@ int eob_test(func_case_t * test_func)
printf("crc null test fail\n"); printf("crc null test fail\n");
} }
buf = (unsigned char *)buf_alloc; //reset buf buf = (unsigned char *) buf_alloc; // reset buf
buf = buf + ((MAX_BUF - 1) * TEST_SIZE); //Line up TEST_SIZE from end buf = buf + ((MAX_BUF - 1) * TEST_SIZE); // Line up TEST_SIZE from end
for (i = 0; i <= TEST_SIZE; i++) { for (i = 0; i <= TEST_SIZE; i++) {
crc_ref = test_func->crc32_ref_call(TEST_SEED, buf + i, TEST_SIZE - i); crc_ref = test_func->crc32_ref_call(TEST_SEED, buf + i, TEST_SIZE - i);
crc_base = test_func->crc32_base_call(TEST_SEED, buf + i, TEST_SIZE - i); crc_base = test_func->crc32_base_call(TEST_SEED, buf + i, TEST_SIZE - i);
@ -295,8 +305,8 @@ int eob_test(func_case_t * test_func)
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail crc eob rand%3d = 0x%8x 0x%8x 0x%8x\n", i, crc_ref, printf("fail crc eob rand%3d = 0x%8x 0x%8x 0x%8x\n", i, crc_ref, crc_base,
crc_base, crc); crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else if (i % (TEST_SIZE / 8) == 0) else if (i % (TEST_SIZE / 8) == 0)
@ -307,7 +317,8 @@ int eob_test(func_case_t * test_func)
return fail; return fail;
} }
int update_test(func_case_t * test_func) int
update_test(func_case_t *test_func)
{ {
uint32_t crc_ref, crc_base, crc; uint32_t crc_ref, crc_base, crc;
int fail = 0; int fail = 0;
@ -315,7 +326,7 @@ int update_test(func_case_t * test_func)
uint64_t r; uint64_t r;
unsigned char *buf = NULL; unsigned char *buf = NULL;
buf = (unsigned char *)buf_alloc; //reset buf buf = (unsigned char *) buf_alloc; // reset buf
r = rand(); r = rand();
// Process the whole buf with reference func single call. // Process the whole buf with reference func single call.
crc_ref = test_func->crc32_ref_call(r, buf, MAX_BUF * TEST_SIZE); crc_ref = test_func->crc32_ref_call(r, buf, MAX_BUF * TEST_SIZE);

View File

@ -35,26 +35,27 @@
#include "test.h" #include "test.h"
#ifndef GT_L3_CACHE #ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ #define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif #endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM) #if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset // Cached test, loop many times over small dataset
# define TEST_LEN 8*1024 #define TEST_LEN 8 * 1024
# define TEST_TYPE_STR "_warm" #define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST) #elif defined(COLD_TEST)
// Uncached test. Pull from large mem base. // Uncached test. Pull from large mem base.
# define TEST_LEN (2 * GT_L3_CACHE) #define TEST_LEN (2 * GT_L3_CACHE)
# define TEST_TYPE_STR "_cold" #define TEST_TYPE_STR "_cold"
#endif #endif
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
#define TEST_MEM TEST_LEN #define TEST_MEM TEST_LEN
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
void *buf; void *buf;
uint32_t crc; uint32_t crc;
@ -73,7 +74,7 @@ int main(int argc, char *argv[])
memset(buf, 0, TEST_LEN); memset(buf, 0, TEST_LEN);
BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_gzip_refl(TEST_SEED, buf, TEST_LEN)); BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_gzip_refl(TEST_SEED, buf, TEST_LEN));
printf("crc32_gzip_refl" TEST_TYPE_STR ": "); printf("crc32_gzip_refl" TEST_TYPE_STR ": ");
perf_print(start, (long long)TEST_LEN); perf_print(start, (long long) TEST_LEN);
printf("finish 0x%x\n", crc); printf("finish 0x%x\n", crc);
@ -81,10 +82,9 @@ int main(int argc, char *argv[])
printf("Start timed tests\n"); printf("Start timed tests\n");
fflush(0); fflush(0);
BENCHMARK(&start, BENCHMARK_TIME, crc = BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_gzip_refl_base(TEST_SEED, buf, TEST_LEN));
crc32_gzip_refl_base(TEST_SEED, buf, TEST_LEN));
printf("crc32_gzip_refl_base" TEST_TYPE_STR ": "); printf("crc32_gzip_refl_base" TEST_TYPE_STR ": ");
perf_print(start, (long long)TEST_LEN); perf_print(start, (long long) TEST_LEN);
printf("finish 0x%x\n", crc); printf("finish 0x%x\n", crc);

View File

@ -35,26 +35,27 @@
#include "test.h" #include "test.h"
#ifndef GT_L3_CACHE #ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ #define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif #endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM) #if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset // Cached test, loop many times over small dataset
# define TEST_LEN 8*1024 #define TEST_LEN 8 * 1024
# define TEST_TYPE_STR "_warm" #define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST) #elif defined(COLD_TEST)
// Uncached test. Pull from large mem base. // Uncached test. Pull from large mem base.
# define TEST_LEN (2 * GT_L3_CACHE) #define TEST_LEN (2 * GT_L3_CACHE)
# define TEST_TYPE_STR "_cold" #define TEST_TYPE_STR "_cold"
#endif #endif
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
#define TEST_MEM TEST_LEN #define TEST_MEM TEST_LEN
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
void *buf; void *buf;
uint32_t crc; uint32_t crc;
@ -73,7 +74,7 @@ int main(int argc, char *argv[])
memset(buf, 0, TEST_LEN); memset(buf, 0, TEST_LEN);
BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_ieee(TEST_SEED, buf, TEST_LEN)); BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_ieee(TEST_SEED, buf, TEST_LEN));
printf("crc32_ieee" TEST_TYPE_STR ": "); printf("crc32_ieee" TEST_TYPE_STR ": ");
perf_print(start, (long long)TEST_LEN); perf_print(start, (long long) TEST_LEN);
printf("finish 0x%x\n", crc); printf("finish 0x%x\n", crc);
return 0; return 0;

View File

@ -35,26 +35,27 @@
#include "test.h" #include "test.h"
#ifndef GT_L3_CACHE #ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ #define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif #endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM) #if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset // Cached test, loop many times over small dataset
# define TEST_LEN 8*1024 #define TEST_LEN 8 * 1024
# define TEST_TYPE_STR "_warm" #define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST) #elif defined(COLD_TEST)
// Uncached test. Pull from large mem base. // Uncached test. Pull from large mem base.
# define TEST_LEN (2 * GT_L3_CACHE) #define TEST_LEN (2 * GT_L3_CACHE)
# define TEST_TYPE_STR "_cold" #define TEST_TYPE_STR "_cold"
#endif #endif
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
#define TEST_MEM TEST_LEN #define TEST_MEM TEST_LEN
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
void *buf; void *buf;
uint32_t crc; uint32_t crc;
@ -73,7 +74,7 @@ int main(int argc, char *argv[])
memset(buf, 0, TEST_LEN); memset(buf, 0, TEST_LEN);
BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_iscsi(buf, TEST_LEN, TEST_SEED)); BENCHMARK(&start, BENCHMARK_TIME, crc = crc32_iscsi(buf, TEST_LEN, TEST_SEED));
printf("crc32_iscsi" TEST_TYPE_STR ": "); printf("crc32_iscsi" TEST_TYPE_STR ": ");
perf_print(start, (long long)TEST_LEN); perf_print(start, (long long) TEST_LEN);
printf("finish 0x%x\n", crc); printf("finish 0x%x\n", crc);
return 0; return 0;

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,8 @@
#define BUF_SIZE 8192 #define BUF_SIZE 8192
#define INIT_SEED 0x12345678 #define INIT_SEED 0x12345678
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
uint8_t inbuf[BUF_SIZE]; uint8_t inbuf[BUF_SIZE];
uint64_t avail_in, total_in = 0; uint64_t avail_in, total_in = 0;

View File

@ -37,26 +37,26 @@
#include "test.h" #include "test.h"
#ifndef GT_L3_CACHE #ifndef GT_L3_CACHE
# define GT_L3_CACHE 32*1024*1024 /* some number > last level cache */ #define GT_L3_CACHE 32 * 1024 * 1024 /* some number > last level cache */
#endif #endif
#if !defined(COLD_TEST) && !defined(TEST_CUSTOM) #if !defined(COLD_TEST) && !defined(TEST_CUSTOM)
// Cached test, loop many times over small dataset // Cached test, loop many times over small dataset
# define TEST_LEN 8*1024 #define TEST_LEN 8 * 1024
# define TEST_TYPE_STR "_warm" #define TEST_TYPE_STR "_warm"
#elif defined (COLD_TEST) #elif defined(COLD_TEST)
// Uncached test. Pull from large mem base. // Uncached test. Pull from large mem base.
# define TEST_LEN (2 * GT_L3_CACHE) #define TEST_LEN (2 * GT_L3_CACHE)
# define TEST_TYPE_STR "_cold" #define TEST_TYPE_STR "_cold"
#endif #endif
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
#define TEST_MEM TEST_LEN #define TEST_MEM TEST_LEN
typedef uint64_t(*crc64_func_t) (uint64_t, const uint8_t *, uint64_t); typedef uint64_t (*crc64_func_t)(uint64_t, const uint8_t *, uint64_t);
typedef struct func_case { typedef struct func_case {
char *note; char *note;
@ -65,17 +65,18 @@ typedef struct func_case {
} func_case_t; } func_case_t;
func_case_t test_funcs[] = { func_case_t test_funcs[] = {
{"crc64_ecma_norm", crc64_ecma_norm, crc64_ecma_norm_base}, { "crc64_ecma_norm", crc64_ecma_norm, crc64_ecma_norm_base },
{"crc64_ecma_refl", crc64_ecma_refl, crc64_ecma_refl_base}, { "crc64_ecma_refl", crc64_ecma_refl, crc64_ecma_refl_base },
{"crc64_iso_norm", crc64_iso_norm, crc64_iso_norm_base}, { "crc64_iso_norm", crc64_iso_norm, crc64_iso_norm_base },
{"crc64_iso_refl", crc64_iso_refl, crc64_iso_refl_base}, { "crc64_iso_refl", crc64_iso_refl, crc64_iso_refl_base },
{"crc64_jones_norm", crc64_jones_norm, crc64_jones_norm_base}, { "crc64_jones_norm", crc64_jones_norm, crc64_jones_norm_base },
{"crc64_jones_refl", crc64_jones_refl, crc64_jones_refl_base}, { "crc64_jones_refl", crc64_jones_refl, crc64_jones_refl_base },
{"crc64_rocksoft_norm", crc64_rocksoft_norm, crc64_rocksoft_norm_base}, { "crc64_rocksoft_norm", crc64_rocksoft_norm, crc64_rocksoft_norm_base },
{"crc64_rocksoft_refl", crc64_rocksoft_refl, crc64_rocksoft_refl_base} { "crc64_rocksoft_refl", crc64_rocksoft_refl, crc64_rocksoft_refl_base }
}; };
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int j; int j;
void *buf; void *buf;
@ -87,7 +88,7 @@ int main(int argc, char *argv[])
printf("alloc error: Fail"); printf("alloc error: Fail");
return -1; return -1;
} }
memset(buf, (char)TEST_SEED, TEST_LEN); memset(buf, (char) TEST_SEED, TEST_LEN);
for (j = 0; j < sizeof(test_funcs) / sizeof(test_funcs[0]); j++) { for (j = 0; j < sizeof(test_funcs) / sizeof(test_funcs[0]); j++) {
test_func = &test_funcs[j]; test_func = &test_funcs[j];
@ -96,10 +97,10 @@ int main(int argc, char *argv[])
printf("Start timed tests\n"); printf("Start timed tests\n");
fflush(0); fflush(0);
BENCHMARK(&start, BENCHMARK_TIME, crc = BENCHMARK(&start, BENCHMARK_TIME,
test_func->crc64_func_call(TEST_SEED, buf, TEST_LEN)); crc = test_func->crc64_func_call(TEST_SEED, buf, TEST_LEN));
printf("%s" TEST_TYPE_STR ": ", test_func->note); printf("%s" TEST_TYPE_STR ": ", test_func->note);
perf_print(start, (long long)TEST_LEN); perf_print(start, (long long) TEST_LEN);
printf("finish 0x%" PRIx64 "\n", crc); printf("finish 0x%" PRIx64 "\n", crc);
} }

View File

@ -38,7 +38,7 @@
#include "test.h" #include "test.h"
#ifndef TEST_SEED #ifndef TEST_SEED
# define TEST_SEED 0x1234 #define TEST_SEED 0x1234
#endif #endif
#define MAX_BUF 4096 #define MAX_BUF 4096
@ -49,7 +49,7 @@ typedef uint32_t u32;
typedef uint16_t u16; typedef uint16_t u16;
typedef uint8_t u8; typedef uint8_t u8;
typedef uint64_t(*crc64_func_t) (uint64_t, const uint8_t *, uint64_t); typedef uint64_t (*crc64_func_t)(uint64_t, const uint8_t *, uint64_t);
typedef struct func_case { typedef struct func_case {
char *note; char *note;
@ -59,22 +59,22 @@ typedef struct func_case {
} func_case_t; } func_case_t;
func_case_t test_funcs[] = { func_case_t test_funcs[] = {
{"crc64_ecma_norm", crc64_ecma_norm, crc64_ecma_norm_base, crc64_ecma_norm_ref}, { "crc64_ecma_norm", crc64_ecma_norm, crc64_ecma_norm_base, crc64_ecma_norm_ref },
{"crc64_ecma_refl", crc64_ecma_refl, crc64_ecma_refl_base, crc64_ecma_refl_ref}, { "crc64_ecma_refl", crc64_ecma_refl, crc64_ecma_refl_base, crc64_ecma_refl_ref },
{"crc64_iso_norm", crc64_iso_norm, crc64_iso_norm_base, crc64_iso_norm_ref}, { "crc64_iso_norm", crc64_iso_norm, crc64_iso_norm_base, crc64_iso_norm_ref },
{"crc64_iso_refl", crc64_iso_refl, crc64_iso_refl_base, crc64_iso_refl_ref}, { "crc64_iso_refl", crc64_iso_refl, crc64_iso_refl_base, crc64_iso_refl_ref },
{"crc64_jones_norm", crc64_jones_norm, crc64_jones_norm_base, { "crc64_jones_norm", crc64_jones_norm, crc64_jones_norm_base, crc64_jones_norm_ref },
crc64_jones_norm_ref}, { "crc64_jones_refl", crc64_jones_refl, crc64_jones_refl_base, crc64_jones_refl_ref },
{"crc64_jones_refl", crc64_jones_refl, crc64_jones_refl_base, crc64_jones_refl_ref}, { "crc64_rocksoft_norm", crc64_rocksoft_norm, crc64_rocksoft_norm_base,
{"crc64_rocksoft_norm", crc64_rocksoft_norm, crc64_rocksoft_norm_base, crc64_rocksoft_norm_ref },
crc64_rocksoft_norm_ref}, { "crc64_rocksoft_refl", crc64_rocksoft_refl, crc64_rocksoft_refl_base,
{"crc64_rocksoft_refl", crc64_rocksoft_refl, crc64_rocksoft_refl_base, crc64_rocksoft_refl_ref }
crc64_rocksoft_refl_ref}
}; };
// Generates pseudo-random data // Generates pseudo-random data
void rand_buffer(unsigned char *buf, long buffer_size) void
rand_buffer(unsigned char *buf, long buffer_size)
{ {
long i; long i;
for (i = 0; i < buffer_size; i++) for (i = 0; i < buffer_size; i++)
@ -82,19 +82,25 @@ void rand_buffer(unsigned char *buf, long buffer_size)
} }
// Test cases // Test cases
int zeros_test(func_case_t * test_func); int
zeros_test(func_case_t *test_func);
int simple_pattern_test(func_case_t * test_func); int
simple_pattern_test(func_case_t *test_func);
int seeds_sizes_test(func_case_t * test_func); int
seeds_sizes_test(func_case_t *test_func);
int eob_test(func_case_t * test_func); int
eob_test(func_case_t *test_func);
int update_test(func_case_t * test_func); int
update_test(func_case_t *test_func);
void *buf_alloc = NULL; void *buf_alloc = NULL;
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
int fail = 0, fail_case; int fail = 0, fail_case;
int i, ret; int i, ret;
@ -135,13 +141,14 @@ int main(int argc, char *argv[])
} }
// Test of all zeros // Test of all zeros
int zeros_test(func_case_t * test_func) int
zeros_test(func_case_t *test_func)
{ {
uint64_t crc_ref, crc_base, crc; uint64_t crc_ref, crc_base, crc;
int fail = 0; int fail = 0;
unsigned char *buf = NULL; unsigned char *buf = NULL;
buf = (unsigned char *)buf_alloc; buf = (unsigned char *) buf_alloc;
memset(buf, 0, MAX_BUF * 10); memset(buf, 0, MAX_BUF * 10);
crc_ref = test_func->crc64_ref_call(TEST_SEED, buf, MAX_BUF * 10); crc_ref = test_func->crc64_ref_call(TEST_SEED, buf, MAX_BUF * 10);
crc_base = test_func->crc64_base_call(TEST_SEED, buf, MAX_BUF * 10); crc_base = test_func->crc64_base_call(TEST_SEED, buf, MAX_BUF * 10);
@ -163,13 +170,14 @@ int zeros_test(func_case_t * test_func)
} }
// Another simple test pattern // Another simple test pattern
int simple_pattern_test(func_case_t * test_func) int
simple_pattern_test(func_case_t *test_func)
{ {
uint64_t crc_ref, crc_base, crc; uint64_t crc_ref, crc_base, crc;
int fail = 0; int fail = 0;
unsigned char *buf = NULL; unsigned char *buf = NULL;
buf = (unsigned char *)buf_alloc; buf = (unsigned char *) buf_alloc;
memset(buf, 0x8a, MAX_BUF); memset(buf, 0x8a, MAX_BUF);
crc_ref = test_func->crc64_ref_call(TEST_SEED, buf, MAX_BUF); crc_ref = test_func->crc64_ref_call(TEST_SEED, buf, MAX_BUF);
crc_base = test_func->crc64_base_call(TEST_SEED, buf, MAX_BUF); crc_base = test_func->crc64_base_call(TEST_SEED, buf, MAX_BUF);
@ -177,8 +185,8 @@ int simple_pattern_test(func_case_t * test_func)
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail crc all 8a = 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 "\n", printf("fail crc all 8a = 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 "\n", crc_ref,
crc_ref, crc_base, crc); crc_base, crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else else
@ -187,7 +195,8 @@ int simple_pattern_test(func_case_t * test_func)
return fail; return fail;
} }
int seeds_sizes_test(func_case_t * test_func) int
seeds_sizes_test(func_case_t *test_func)
{ {
uint64_t crc_ref, crc_base, crc; uint64_t crc_ref, crc_base, crc;
int fail = 0; int fail = 0;
@ -196,7 +205,7 @@ int seeds_sizes_test(func_case_t * test_func)
unsigned char *buf = NULL; unsigned char *buf = NULL;
// Do a few random tests // Do a few random tests
buf = (unsigned char *)buf_alloc; //reset buf buf = (unsigned char *) buf_alloc; // reset buf
r = rand(); r = rand();
rand_buffer(buf, MAX_BUF * TEST_SIZE); rand_buffer(buf, MAX_BUF * TEST_SIZE);
@ -207,8 +216,8 @@ int seeds_sizes_test(func_case_t * test_func)
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail crc rand%3d = 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 printf("fail crc rand%3d = 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 "\n", i,
"\n", i, crc_ref, crc_base, crc); crc_ref, crc_base, crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else if (i % (TEST_SIZE / 8) == 0) else if (i % (TEST_SIZE / 8) == 0)
@ -218,7 +227,7 @@ int seeds_sizes_test(func_case_t * test_func)
} }
// Do a few random sizes // Do a few random sizes
buf = (unsigned char *)buf_alloc; //reset buf buf = (unsigned char *) buf_alloc; // reset buf
r = rand(); r = rand();
for (i = MAX_BUF; i >= 0; i--) { for (i = MAX_BUF; i >= 0; i--) {
@ -228,8 +237,8 @@ int seeds_sizes_test(func_case_t * test_func)
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail random size %d 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 printf("fail random size %d 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 "\n", i,
"\n", i, crc_ref, crc_base, crc); crc_ref, crc_base, crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else if (i % (MAX_BUF / 8) == 0) else if (i % (MAX_BUF / 8) == 0)
@ -239,7 +248,7 @@ int seeds_sizes_test(func_case_t * test_func)
// Try different seeds // Try different seeds
for (s = 0; s < 20; s++) { for (s = 0; s < 20; s++) {
buf = (unsigned char *)buf_alloc; //reset buf buf = (unsigned char *) buf_alloc; // reset buf
r = rand(); // just to get a new seed r = rand(); // just to get a new seed
rand_buffer(buf, MAX_BUF * TEST_SIZE); // new pseudo-rand data rand_buffer(buf, MAX_BUF * TEST_SIZE); // new pseudo-rand data
@ -255,8 +264,9 @@ int seeds_sizes_test(func_case_t * test_func)
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail crc rand%3d = 0x%" PRIx64 " 0x%" PRIx64 " 0x%" printf("fail crc rand%3d = 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64
PRIx64 "\n", i, crc_ref, crc_base, crc); "\n",
i, crc_ref, crc_base, crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else if (i % (TEST_SIZE * 20 / 8) == 0) else if (i % (TEST_SIZE * 20 / 8) == 0)
@ -270,7 +280,8 @@ int seeds_sizes_test(func_case_t * test_func)
} }
// Run tests at end of buffer // Run tests at end of buffer
int eob_test(func_case_t * test_func) int
eob_test(func_case_t *test_func)
{ {
uint64_t crc_ref, crc_base, crc; uint64_t crc_ref, crc_base, crc;
int fail = 0; int fail = 0;
@ -283,8 +294,8 @@ int eob_test(func_case_t * test_func)
printf("crc null test fail\n"); printf("crc null test fail\n");
} }
buf = (unsigned char *)buf_alloc; //reset buf buf = (unsigned char *) buf_alloc; // reset buf
buf = buf + ((MAX_BUF - 1) * TEST_SIZE); //Line up TEST_SIZE from end buf = buf + ((MAX_BUF - 1) * TEST_SIZE); // Line up TEST_SIZE from end
for (i = 0; i <= TEST_SIZE; i++) { for (i = 0; i <= TEST_SIZE; i++) {
crc_ref = test_func->crc64_ref_call(TEST_SEED, buf + i, TEST_SIZE - i); crc_ref = test_func->crc64_ref_call(TEST_SEED, buf + i, TEST_SIZE - i);
crc_base = test_func->crc64_base_call(TEST_SEED, buf + i, TEST_SIZE - i); crc_base = test_func->crc64_base_call(TEST_SEED, buf + i, TEST_SIZE - i);
@ -292,8 +303,8 @@ int eob_test(func_case_t * test_func)
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail crc eob rand%3d = 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 printf("fail crc eob rand%3d = 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 "\n",
"\n", i, crc_ref, crc_base, crc); i, crc_ref, crc_base, crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else if (i % (TEST_SIZE / 8) == 0) else if (i % (TEST_SIZE / 8) == 0)
@ -304,7 +315,8 @@ int eob_test(func_case_t * test_func)
return fail; return fail;
} }
int update_test(func_case_t * test_func) int
update_test(func_case_t *test_func)
{ {
uint64_t crc_ref, crc_base, crc; uint64_t crc_ref, crc_base, crc;
int fail = 0; int fail = 0;
@ -312,7 +324,7 @@ int update_test(func_case_t * test_func)
uint64_t r; uint64_t r;
unsigned char *buf = NULL; unsigned char *buf = NULL;
buf = (unsigned char *)buf_alloc; //reset buf buf = (unsigned char *) buf_alloc; // reset buf
r = rand(); r = rand();
// Process the whole buf with reference func single call. // Process the whole buf with reference func single call.
crc_ref = test_func->crc64_ref_call(r, buf, MAX_BUF * TEST_SIZE); crc_ref = test_func->crc64_ref_call(r, buf, MAX_BUF * TEST_SIZE);
@ -327,8 +339,8 @@ int update_test(func_case_t * test_func)
if ((crc_base != crc_ref) || (crc != crc_ref)) { if ((crc_base != crc_ref) || (crc != crc_ref)) {
fail++; fail++;
printf("fail crc rand%3d = 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 "\n", i, printf("fail crc rand%3d = 0x%" PRIx64 " 0x%" PRIx64 " 0x%" PRIx64 "\n", i, crc_ref,
crc_ref, crc_base, crc); crc_base, crc);
} }
#ifdef TEST_VERBOSE #ifdef TEST_VERBOSE
else else

View File

@ -37,13 +37,14 @@ extern "C" {
#include "crc64.h" #include "crc64.h"
#ifdef _MSC_VER #ifdef _MSC_VER
# define inline __inline #define inline __inline
#endif #endif
#define MAX_ITER 8 #define MAX_ITER 8
// crc64_ecma reference function, slow crc64 from the definition. // crc64_ecma reference function, slow crc64 from the definition.
static inline uint64_t crc64_ecma_refl_ref(uint64_t seed, const uint8_t * buf, uint64_t len) static inline uint64_t
crc64_ecma_refl_ref(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
uint64_t rem = ~seed; uint64_t rem = ~seed;
unsigned int i, j; unsigned int i, j;
@ -59,7 +60,8 @@ static inline uint64_t crc64_ecma_refl_ref(uint64_t seed, const uint8_t * buf, u
return ~rem; return ~rem;
} }
static inline uint64_t crc64_ecma_norm_ref(uint64_t seed, const uint8_t * buf, uint64_t len) static inline uint64_t
crc64_ecma_norm_ref(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
uint64_t rem = ~seed; uint64_t rem = ~seed;
unsigned int i, j; unsigned int i, j;
@ -76,7 +78,8 @@ static inline uint64_t crc64_ecma_norm_ref(uint64_t seed, const uint8_t * buf, u
} }
// crc64_iso reference function, slow crc64 from the definition. // crc64_iso reference function, slow crc64 from the definition.
static inline uint64_t crc64_iso_refl_ref(uint64_t seed, const uint8_t * buf, uint64_t len) static inline uint64_t
crc64_iso_refl_ref(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
uint64_t rem = ~seed; uint64_t rem = ~seed;
unsigned int i, j; unsigned int i, j;
@ -92,7 +95,8 @@ static inline uint64_t crc64_iso_refl_ref(uint64_t seed, const uint8_t * buf, ui
return ~rem; return ~rem;
} }
static inline uint64_t crc64_iso_norm_ref(uint64_t seed, const uint8_t * buf, uint64_t len) static inline uint64_t
crc64_iso_norm_ref(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
uint64_t rem = ~seed; uint64_t rem = ~seed;
unsigned int i, j; unsigned int i, j;
@ -109,7 +113,8 @@ static inline uint64_t crc64_iso_norm_ref(uint64_t seed, const uint8_t * buf, ui
} }
// crc64_jones reference function, slow crc64 from the definition. // crc64_jones reference function, slow crc64 from the definition.
static inline uint64_t crc64_jones_refl_ref(uint64_t seed, const uint8_t * buf, uint64_t len) static inline uint64_t
crc64_jones_refl_ref(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
uint64_t rem = ~seed; uint64_t rem = ~seed;
unsigned int i, j; unsigned int i, j;
@ -125,7 +130,8 @@ static inline uint64_t crc64_jones_refl_ref(uint64_t seed, const uint8_t * buf,
return ~rem; return ~rem;
} }
static inline uint64_t crc64_jones_norm_ref(uint64_t seed, const uint8_t * buf, uint64_t len) static inline uint64_t
crc64_jones_norm_ref(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
uint64_t rem = ~seed; uint64_t rem = ~seed;
unsigned int i, j; unsigned int i, j;
@ -141,9 +147,9 @@ static inline uint64_t crc64_jones_norm_ref(uint64_t seed, const uint8_t * buf,
return ~rem; return ~rem;
} }
// crc64_rocksoft reference function, slow crc64 from the definition. // crc64_rocksoft reference function, slow crc64 from the definition.
static inline uint64_t crc64_rocksoft_refl_ref(uint64_t seed, const uint8_t * buf, uint64_t len) static inline uint64_t
crc64_rocksoft_refl_ref(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
uint64_t rem = ~seed; uint64_t rem = ~seed;
unsigned int i, j; unsigned int i, j;
@ -159,7 +165,8 @@ static inline uint64_t crc64_rocksoft_refl_ref(uint64_t seed, const uint8_t * bu
return ~rem; return ~rem;
} }
static inline uint64_t crc64_rocksoft_norm_ref(uint64_t seed, const uint8_t * buf, uint64_t len) static inline uint64_t
crc64_rocksoft_norm_ref(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
uint64_t rem = ~seed; uint64_t rem = ~seed;
unsigned int i, j; unsigned int i, j;

View File

@ -30,242 +30,154 @@
#include "crc.h" #include "crc.h"
static const uint16_t crc16tab[256] = { static const uint16_t crc16tab[256] = {
0x0000, 0x8BB7, 0x9CD9, 0x176E, 0xB205, 0x39B2, 0x2EDC, 0xA56B, 0x0000, 0x8BB7, 0x9CD9, 0x176E, 0xB205, 0x39B2, 0x2EDC, 0xA56B, 0xEFBD, 0x640A, 0x7364,
0xEFBD, 0x640A, 0x7364, 0xF8D3, 0x5DB8, 0xD60F, 0xC161, 0x4AD6, 0xF8D3, 0x5DB8, 0xD60F, 0xC161, 0x4AD6, 0x54CD, 0xDF7A, 0xC814, 0x43A3, 0xE6C8, 0x6D7F,
0x54CD, 0xDF7A, 0xC814, 0x43A3, 0xE6C8, 0x6D7F, 0x7A11, 0xF1A6, 0x7A11, 0xF1A6, 0xBB70, 0x30C7, 0x27A9, 0xAC1E, 0x0975, 0x82C2, 0x95AC, 0x1E1B, 0xA99A,
0xBB70, 0x30C7, 0x27A9, 0xAC1E, 0x0975, 0x82C2, 0x95AC, 0x1E1B, 0x222D, 0x3543, 0xBEF4, 0x1B9F, 0x9028, 0x8746, 0x0CF1, 0x4627, 0xCD90, 0xDAFE, 0x5149,
0xA99A, 0x222D, 0x3543, 0xBEF4, 0x1B9F, 0x9028, 0x8746, 0x0CF1, 0xF422, 0x7F95, 0x68FB, 0xE34C, 0xFD57, 0x76E0, 0x618E, 0xEA39, 0x4F52, 0xC4E5, 0xD38B,
0x4627, 0xCD90, 0xDAFE, 0x5149, 0xF422, 0x7F95, 0x68FB, 0xE34C, 0x583C, 0x12EA, 0x995D, 0x8E33, 0x0584, 0xA0EF, 0x2B58, 0x3C36, 0xB781, 0xD883, 0x5334,
0xFD57, 0x76E0, 0x618E, 0xEA39, 0x4F52, 0xC4E5, 0xD38B, 0x583C, 0x445A, 0xCFED, 0x6A86, 0xE131, 0xF65F, 0x7DE8, 0x373E, 0xBC89, 0xABE7, 0x2050, 0x853B,
0x12EA, 0x995D, 0x8E33, 0x0584, 0xA0EF, 0x2B58, 0x3C36, 0xB781, 0x0E8C, 0x19E2, 0x9255, 0x8C4E, 0x07F9, 0x1097, 0x9B20, 0x3E4B, 0xB5FC, 0xA292, 0x2925,
0xD883, 0x5334, 0x445A, 0xCFED, 0x6A86, 0xE131, 0xF65F, 0x7DE8, 0x63F3, 0xE844, 0xFF2A, 0x749D, 0xD1F6, 0x5A41, 0x4D2F, 0xC698, 0x7119, 0xFAAE, 0xEDC0,
0x373E, 0xBC89, 0xABE7, 0x2050, 0x853B, 0x0E8C, 0x19E2, 0x9255, 0x6677, 0xC31C, 0x48AB, 0x5FC5, 0xD472, 0x9EA4, 0x1513, 0x027D, 0x89CA, 0x2CA1, 0xA716,
0x8C4E, 0x07F9, 0x1097, 0x9B20, 0x3E4B, 0xB5FC, 0xA292, 0x2925, 0xB078, 0x3BCF, 0x25D4, 0xAE63, 0xB90D, 0x32BA, 0x97D1, 0x1C66, 0x0B08, 0x80BF, 0xCA69,
0x63F3, 0xE844, 0xFF2A, 0x749D, 0xD1F6, 0x5A41, 0x4D2F, 0xC698, 0x41DE, 0x56B0, 0xDD07, 0x786C, 0xF3DB, 0xE4B5, 0x6F02, 0x3AB1, 0xB106, 0xA668, 0x2DDF,
0x7119, 0xFAAE, 0xEDC0, 0x6677, 0xC31C, 0x48AB, 0x5FC5, 0xD472, 0x88B4, 0x0303, 0x146D, 0x9FDA, 0xD50C, 0x5EBB, 0x49D5, 0xC262, 0x6709, 0xECBE, 0xFBD0,
0x9EA4, 0x1513, 0x027D, 0x89CA, 0x2CA1, 0xA716, 0xB078, 0x3BCF, 0x7067, 0x6E7C, 0xE5CB, 0xF2A5, 0x7912, 0xDC79, 0x57CE, 0x40A0, 0xCB17, 0x81C1, 0x0A76,
0x25D4, 0xAE63, 0xB90D, 0x32BA, 0x97D1, 0x1C66, 0x0B08, 0x80BF, 0x1D18, 0x96AF, 0x33C4, 0xB873, 0xAF1D, 0x24AA, 0x932B, 0x189C, 0x0FF2, 0x8445, 0x212E,
0xCA69, 0x41DE, 0x56B0, 0xDD07, 0x786C, 0xF3DB, 0xE4B5, 0x6F02, 0xAA99, 0xBDF7, 0x3640, 0x7C96, 0xF721, 0xE04F, 0x6BF8, 0xCE93, 0x4524, 0x524A, 0xD9FD,
0x3AB1, 0xB106, 0xA668, 0x2DDF, 0x88B4, 0x0303, 0x146D, 0x9FDA, 0xC7E6, 0x4C51, 0x5B3F, 0xD088, 0x75E3, 0xFE54, 0xE93A, 0x628D, 0x285B, 0xA3EC, 0xB482,
0xD50C, 0x5EBB, 0x49D5, 0xC262, 0x6709, 0xECBE, 0xFBD0, 0x7067, 0x3F35, 0x9A5E, 0x11E9, 0x0687, 0x8D30, 0xE232, 0x6985, 0x7EEB, 0xF55C, 0x5037, 0xDB80,
0x6E7C, 0xE5CB, 0xF2A5, 0x7912, 0xDC79, 0x57CE, 0x40A0, 0xCB17, 0xCCEE, 0x4759, 0x0D8F, 0x8638, 0x9156, 0x1AE1, 0xBF8A, 0x343D, 0x2353, 0xA8E4, 0xB6FF,
0x81C1, 0x0A76, 0x1D18, 0x96AF, 0x33C4, 0xB873, 0xAF1D, 0x24AA, 0x3D48, 0x2A26, 0xA191, 0x04FA, 0x8F4D, 0x9823, 0x1394, 0x5942, 0xD2F5, 0xC59B, 0x4E2C,
0x932B, 0x189C, 0x0FF2, 0x8445, 0x212E, 0xAA99, 0xBDF7, 0x3640, 0xEB47, 0x60F0, 0x779E, 0xFC29, 0x4BA8, 0xC01F, 0xD771, 0x5CC6, 0xF9AD, 0x721A, 0x6574,
0x7C96, 0xF721, 0xE04F, 0x6BF8, 0xCE93, 0x4524, 0x524A, 0xD9FD, 0xEEC3, 0xA415, 0x2FA2, 0x38CC, 0xB37B, 0x1610, 0x9DA7, 0x8AC9, 0x017E, 0x1F65, 0x94D2,
0xC7E6, 0x4C51, 0x5B3F, 0xD088, 0x75E3, 0xFE54, 0xE93A, 0x628D, 0x83BC, 0x080B, 0xAD60, 0x26D7, 0x31B9, 0xBA0E, 0xF0D8, 0x7B6F, 0x6C01, 0xE7B6, 0x42DD,
0x285B, 0xA3EC, 0xB482, 0x3F35, 0x9A5E, 0x11E9, 0x0687, 0x8D30, 0xC96A, 0xDE04, 0x55B3
0xE232, 0x6985, 0x7EEB, 0xF55C, 0x5037, 0xDB80, 0xCCEE, 0x4759,
0x0D8F, 0x8638, 0x9156, 0x1AE1, 0xBF8A, 0x343D, 0x2353, 0xA8E4,
0xB6FF, 0x3D48, 0x2A26, 0xA191, 0x04FA, 0x8F4D, 0x9823, 0x1394,
0x5942, 0xD2F5, 0xC59B, 0x4E2C, 0xEB47, 0x60F0, 0x779E, 0xFC29,
0x4BA8, 0xC01F, 0xD771, 0x5CC6, 0xF9AD, 0x721A, 0x6574, 0xEEC3,
0xA415, 0x2FA2, 0x38CC, 0xB37B, 0x1610, 0x9DA7, 0x8AC9, 0x017E,
0x1F65, 0x94D2, 0x83BC, 0x080B, 0xAD60, 0x26D7, 0x31B9, 0xBA0E,
0xF0D8, 0x7B6F, 0x6C01, 0xE7B6, 0x42DD, 0xC96A, 0xDE04, 0x55B3
}; };
static const uint32_t crc32_table_iscsi_refl[256] = { static const uint32_t crc32_table_iscsi_refl[256] = {
0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, 0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, 0xC79A971F, 0x35F1141C, 0x26A1E7E8,
0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB, 0xD4CA64EB, 0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B, 0x4D43CFD0, 0xBF284CD3,
0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B, 0xAC78BF27, 0x5E133C24, 0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B, 0xD7C45070,
0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24, 0x25AFD373, 0x36FF2087, 0xC494A384, 0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54,
0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B, 0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B, 0x20BD8EDE, 0xD2D60DDD, 0xC186FE29,
0xD7C45070, 0x25AFD373, 0x36FF2087, 0xC494A384, 0x33ED7D2A, 0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35, 0xAA64D611, 0x580F5512,
0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54, 0x4B5FA6E6, 0xB93425E5, 0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA, 0x30E349B1,
0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B, 0xC288CAB2, 0xD1D83946, 0x23B3BA45, 0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A,
0x20BD8EDE, 0xD2D60DDD, 0xC186FE29, 0x33ED7D2A, 0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A, 0x7DA08661, 0x8FCB0562, 0x9C9BF696,
0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35, 0x6EF07595, 0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48, 0x86E18AA3, 0x748A09A0,
0xAA64D611, 0x580F5512, 0x4B5FA6E6, 0xB93425E5, 0x67DAFA54, 0x95B17957, 0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687, 0x0C38D26C,
0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA, 0xFE53516F, 0xED03A29B, 0x1F682198, 0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927,
0x30E349B1, 0xC288CAB2, 0xD1D83946, 0x23B3BA45, 0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38, 0xDBFC821C, 0x2997011F, 0x3AC7F2EB,
0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A, 0xC8AC71E8, 0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7, 0x61C69362, 0x93AD1061,
0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A, 0x80FDE395, 0x72966096, 0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789, 0xEB1FCBAD,
0x7DA08661, 0x8FCB0562, 0x9C9BF696, 0x6EF07595, 0x197448AE, 0x0A24BB5A, 0xF84F3859, 0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46,
0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48, 0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9, 0xB602C312, 0x44694011, 0x5739B3E5,
0x86E18AA3, 0x748A09A0, 0x67DAFA54, 0x95B17957, 0xA55230E6, 0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36, 0x3CDB9BDD, 0xCEB018DE,
0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687, 0xDDE0EB2A, 0x2F8B6829, 0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C, 0x456CAC67,
0x0C38D26C, 0xFE53516F, 0xED03A29B, 0x1F682198, 0xB7072F64, 0xA457DC90, 0x563C5F93, 0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043,
0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927, 0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C, 0x92A8FC17, 0x60C37F14, 0x73938CE0,
0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38, 0x81F80FE3, 0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC, 0x1871A4D8, 0xEA1A27DB,
0xDBFC821C, 0x2997011F, 0x3AC7F2EB, 0xC8AC71E8, 0xF94AD42F, 0x0B21572C, 0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033, 0xA24BB5A6,
0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7, 0x502036A5, 0x4370C551, 0xB11B4652, 0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D,
0x61C69362, 0x93AD1061, 0x80FDE395, 0x72966096, 0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D, 0xEF087A76, 0x1D63F975, 0x0E330A81,
0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789, 0xFC588982, 0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D, 0x758FE5D6, 0x87E466D5,
0xEB1FCBAD, 0x197448AE, 0x0A24BB5A, 0xF84F3859, 0x94B49521, 0x66DF1622, 0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2, 0xFF56BD19,
0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED, 0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530,
0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9, 0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F, 0x49547E0B, 0xBB3FFD08, 0xA86F0EFC,
0xB602C312, 0x44694011, 0x5739B3E5, 0xA55230E6, 0x5A048DFF, 0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0, 0xD3D3E1AB, 0x21B862A8,
0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36, 0x32E8915C, 0xC083125F, 0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540, 0x590AB964,
0x3CDB9BDD, 0xCEB018DE, 0xDDE0EB2A, 0x2F8B6829, 0xAB613A67, 0xB831C993, 0x4A5A4A90, 0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F,
0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C, 0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE, 0x24AA3F05, 0xD6C1BC06, 0xC5914FF2,
0x456CAC67, 0xB7072F64, 0xA457DC90, 0x563C5F93, 0x37FACCF1, 0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321, 0xAE7367CA, 0x5C18E4C9,
0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043, 0x4F48173D, 0xBD23943E, 0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81, 0x34F4F86A,
0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E, 0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E,
0x92A8FC17, 0x60C37F14, 0x73938CE0, 0x81F80FE3,
0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC,
0x1871A4D8, 0xEA1A27DB, 0xF94AD42F, 0x0B21572C,
0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033,
0xA24BB5A6, 0x502036A5, 0x4370C551, 0xB11B4652,
0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D,
0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D,
0xEF087A76, 0x1D63F975, 0x0E330A81, 0xFC588982,
0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D,
0x758FE5D6, 0x87E466D5, 0x94B49521, 0x66DF1622,
0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2,
0xFF56BD19, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED,
0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530,
0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F,
0x49547E0B, 0xBB3FFD08, 0xA86F0EFC, 0x5A048DFF,
0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0,
0xD3D3E1AB, 0x21B862A8, 0x32E8915C, 0xC083125F,
0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540,
0x590AB964, 0xAB613A67, 0xB831C993, 0x4A5A4A90,
0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F,
0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE,
0x24AA3F05, 0xD6C1BC06, 0xC5914FF2, 0x37FACCF1,
0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321,
0xAE7367CA, 0x5C18E4C9, 0x4F48173D, 0xBD23943E,
0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81,
0x34F4F86A, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E,
0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E,
0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351
}; };
static const uint32_t crc32_table_ieee_norm[256] = { static const uint32_t crc32_table_ieee_norm[256] = {
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2,
0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3,
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac,
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011,
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e,
0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, 0x95609039, 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef,
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, 0xd4326d90,
0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a,
0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xec7dd02d, 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c,
0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0x2e003dc5, 0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13,
0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1,
0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, 0xaca5c697, 0xa864db20,
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f,
0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x8e6c3698, 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055,
0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, 0xfef34de2, 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, 0x7a089632,
0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f,
0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e, 0x21dc2629, 0x2c9f00f0,
0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91,
0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, 0x0a97ed48, 0x0e56f0ff, 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e,
0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604,
0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, 0xaafbe615,
0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a,
0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0x8cf30bad, 0x81b02d74, 0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f,
0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, 0x76c15bf8, 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e,
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, 0x3793a651,
0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb,
0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa,
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0xf9278673, 0xfde69bc4, 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5,
0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47,
0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7,
0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f,
0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f,
0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30,
0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088,
0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0,
0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
}; };
static const uint32_t crc32_table_gzip_refl[256] = { static const uint32_t crc32_table_gzip_refl[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535,
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac,
0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb,
0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea,
0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce,
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409,
0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739,
0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0,
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8,
0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703,
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae,
0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6,
0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5,
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
}; };
uint16_t crc16_t10dif_base(uint16_t seed, uint8_t * buf, uint64_t len) uint16_t
crc16_t10dif_base(uint16_t seed, uint8_t *buf, uint64_t len)
{ {
int i; int i;
uint16_t crc = seed; uint16_t crc = seed;
@ -276,7 +188,8 @@ uint16_t crc16_t10dif_base(uint16_t seed, uint8_t * buf, uint64_t len)
return crc; return crc;
} }
uint16_t crc16_t10dif_copy_base(uint16_t seed, uint8_t * dst, uint8_t * src, uint64_t len) uint16_t
crc16_t10dif_copy_base(uint16_t seed, uint8_t *dst, uint8_t *src, uint64_t len)
{ {
int i; int i;
uint16_t crc = seed; uint16_t crc = seed;
@ -289,7 +202,8 @@ uint16_t crc16_t10dif_copy_base(uint16_t seed, uint8_t * dst, uint8_t * src, uin
return crc; return crc;
} }
unsigned int crc32_iscsi_base(unsigned char *buffer, int len, unsigned int crc_init) unsigned int
crc32_iscsi_base(unsigned char *buffer, int len, unsigned int crc_init)
{ {
unsigned int crc; unsigned int crc;
unsigned char *p_buf; unsigned char *p_buf;
@ -304,7 +218,8 @@ unsigned int crc32_iscsi_base(unsigned char *buffer, int len, unsigned int crc_i
return crc; return crc;
} }
uint32_t crc32_ieee_base(uint32_t seed, uint8_t * buf, uint64_t len) uint32_t
crc32_ieee_base(uint32_t seed, uint8_t *buf, uint64_t len)
{ {
unsigned int crc = ~seed; unsigned int crc = ~seed;
@ -316,13 +231,14 @@ uint32_t crc32_ieee_base(uint32_t seed, uint8_t * buf, uint64_t len)
return ~crc; return ~crc;
} }
uint32_t crc32_gzip_refl_base(uint32_t seed, uint8_t * buf, uint64_t len) uint32_t
crc32_gzip_refl_base(uint32_t seed, uint8_t *buf, uint64_t len)
{ {
unsigned int crc; unsigned int crc;
unsigned char *p_buf; unsigned char *p_buf;
unsigned char *p_end = buf + len; unsigned char *p_end = buf + len;
p_buf = (unsigned char *)buf; p_buf = (unsigned char *) buf;
crc = ~seed; crc = ~seed;
while (p_buf < p_end) { while (p_buf < p_end) {

View File

@ -31,67 +31,80 @@
#include "crc64.h" #include "crc64.h"
#include <stdint.h> #include <stdint.h>
unsigned int crc32_iscsi(unsigned char *buffer, int len, unsigned int crc_init) unsigned int
crc32_iscsi(unsigned char *buffer, int len, unsigned int crc_init)
{ {
return crc32_iscsi_base(buffer, len, crc_init); return crc32_iscsi_base(buffer, len, crc_init);
} }
uint16_t crc16_t10dif(uint16_t seed, const unsigned char *buf, uint64_t len) uint16_t
crc16_t10dif(uint16_t seed, const unsigned char *buf, uint64_t len)
{ {
return crc16_t10dif_base(seed, (uint8_t *) buf, len); return crc16_t10dif_base(seed, (uint8_t *) buf, len);
} }
uint16_t crc16_t10dif_copy(uint16_t seed, uint8_t * dst, uint8_t * src, uint64_t len) uint16_t
crc16_t10dif_copy(uint16_t seed, uint8_t *dst, uint8_t *src, uint64_t len)
{ {
return crc16_t10dif_copy_base(seed, dst, src, len); return crc16_t10dif_copy_base(seed, dst, src, len);
} }
uint32_t crc32_ieee(uint32_t seed, const unsigned char *buf, uint64_t len) uint32_t
crc32_ieee(uint32_t seed, const unsigned char *buf, uint64_t len)
{ {
return crc32_ieee_base(seed, (uint8_t *) buf, len); return crc32_ieee_base(seed, (uint8_t *) buf, len);
} }
uint32_t crc32_gzip_refl(uint32_t seed, const unsigned char *buf, uint64_t len) uint32_t
crc32_gzip_refl(uint32_t seed, const unsigned char *buf, uint64_t len)
{ {
return crc32_gzip_refl_base(seed, (uint8_t *) buf, len); return crc32_gzip_refl_base(seed, (uint8_t *) buf, len);
} }
uint64_t crc64_ecma_refl(uint64_t seed, const uint8_t * buf, uint64_t len) uint64_t
crc64_ecma_refl(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc64_ecma_refl_base(seed, buf, len); return crc64_ecma_refl_base(seed, buf, len);
} }
uint64_t crc64_ecma_norm(uint64_t seed, const uint8_t * buf, uint64_t len) uint64_t
crc64_ecma_norm(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc64_ecma_norm_base(seed, buf, len); return crc64_ecma_norm_base(seed, buf, len);
} }
uint64_t crc64_iso_refl(uint64_t seed, const uint8_t * buf, uint64_t len) uint64_t
crc64_iso_refl(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc64_iso_refl_base(seed, buf, len); return crc64_iso_refl_base(seed, buf, len);
} }
uint64_t crc64_iso_norm(uint64_t seed, const uint8_t * buf, uint64_t len) uint64_t
crc64_iso_norm(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc64_iso_norm_base(seed, buf, len); return crc64_iso_norm_base(seed, buf, len);
} }
uint64_t crc64_jones_refl(uint64_t seed, const uint8_t * buf, uint64_t len) uint64_t
crc64_jones_refl(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc64_jones_refl_base(seed, buf, len); return crc64_jones_refl_base(seed, buf, len);
} }
uint64_t crc64_jones_norm(uint64_t seed, const uint8_t * buf, uint64_t len) uint64_t
crc64_jones_norm(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc64_jones_norm_base(seed, buf, len); return crc64_jones_norm_base(seed, buf, len);
} }
uint64_t crc64_rocksoft_refl(uint64_t seed, const uint8_t * buf, uint64_t len) uint64_t
crc64_rocksoft_refl(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc64_rocksoft_refl_base(seed, buf, len); return crc64_rocksoft_refl_base(seed, buf, len);
} }
uint64_t crc64_rocksoft_norm(uint64_t seed, const uint8_t * buf, uint64_t len) uint64_t
crc64_rocksoft_norm(uint64_t seed, const uint8_t *buf, uint64_t len)
{ {
return crc64_rocksoft_norm_base(seed, buf, len); return crc64_rocksoft_norm_base(seed, buf, len);
} }

View File

@ -37,13 +37,14 @@ extern "C" {
#include "crc.h" #include "crc.h"
#ifdef _MSC_VER #ifdef _MSC_VER
# define inline __inline #define inline __inline
#endif #endif
#define MAX_ITER 8 #define MAX_ITER 8
// iSCSI CRC reference function // iSCSI CRC reference function
static inline unsigned int crc32_iscsi_ref(unsigned char *buffer, int len, unsigned int crc_init) static inline unsigned int
crc32_iscsi_ref(unsigned char *buffer, int len, unsigned int crc_init)
{ {
uint64_t rem = crc_init; uint64_t rem = crc_init;
int i, j; int i, j;
@ -60,7 +61,8 @@ static inline unsigned int crc32_iscsi_ref(unsigned char *buffer, int len, unsig
} }
// crc16_t10dif reference function, slow crc16 from the definition. // crc16_t10dif reference function, slow crc16 from the definition.
static inline uint16_t crc16_t10dif_ref(uint16_t seed, uint8_t * buf, uint64_t len) static inline uint16_t
crc16_t10dif_ref(uint16_t seed, uint8_t *buf, uint64_t len)
{ {
size_t rem = seed; size_t rem = seed;
unsigned int i, j; unsigned int i, j;
@ -78,7 +80,8 @@ static inline uint16_t crc16_t10dif_ref(uint16_t seed, uint8_t * buf, uint64_t l
} }
// crc16_t10dif reference function, slow crc16 from the definition. // crc16_t10dif reference function, slow crc16 from the definition.
static inline uint16_t crc16_t10dif_copy_ref(uint16_t seed, uint8_t * dst, uint8_t * src, uint64_t len) static inline uint16_t
crc16_t10dif_copy_ref(uint16_t seed, uint8_t *dst, uint8_t *src, uint64_t len)
{ {
size_t rem = seed; size_t rem = seed;
unsigned int i, j; unsigned int i, j;
@ -97,7 +100,8 @@ static inline uint16_t crc16_t10dif_copy_ref(uint16_t seed, uint8_t * dst, uint8
} }
// crc32_ieee reference function, slow crc32 from the definition. // crc32_ieee reference function, slow crc32 from the definition.
static inline uint32_t crc32_ieee_ref(uint32_t seed, uint8_t * buf, uint64_t len) static inline uint32_t
crc32_ieee_ref(uint32_t seed, uint8_t *buf, uint64_t len)
{ {
uint64_t rem = ~seed; uint64_t rem = ~seed;
unsigned int i, j; unsigned int i, j;
@ -117,7 +121,8 @@ static inline uint32_t crc32_ieee_ref(uint32_t seed, uint8_t * buf, uint64_t len
// crc32_gzip_refl reference function, slow crc32 from the definition. // crc32_gzip_refl reference function, slow crc32 from the definition.
// Please get difference details between crc32_gzip_ref and crc32_ieee // Please get difference details between crc32_gzip_ref and crc32_ieee
// from crc.h. // from crc.h.
static inline uint32_t crc32_gzip_refl_ref(uint32_t seed, uint8_t * buf, uint64_t len) static inline uint32_t
crc32_gzip_refl_ref(uint32_t seed, uint8_t *buf, uint64_t len)
{ {
uint64_t rem = ~seed; uint64_t rem = ~seed;
int i, j; int i, j;

View File

@ -36,7 +36,8 @@ const uint16_t t10_dif_expected = 0x60b3;
const uint32_t init_crc_32 = 0x12345678; const uint32_t init_crc_32 = 0x12345678;
const uint32_t ieee_expected = 0x2ceadbe3; const uint32_t ieee_expected = 0x2ceadbe3;
int main(void) int
main(void)
{ {
unsigned char p_buf[48]; unsigned char p_buf[48];
uint16_t t10_dif_computed; uint16_t t10_dif_computed;