kmalloc: Avoid code duplication.
[dragonfly.git] / test / debug / icrc32.c
blobbf0fcae5f5659e47f822948f9bee884386dae77a
2 /*
3 * cc crc32.c /usr/src/sys/libkern/{crc32.c,icrc32.c} -o ~/bin/crc32
4 */
6 #include <sys/types.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
11 uint32_t iscsi_crc32(const void *buf, size_t size);
12 uint32_t iscsi_crc32_ext(const void *buf, size_t size, uint32_t ocrc);
13 uint32_t crc32(const void *buf, size_t size);
14 uint32_t crc32_ext(const void *buf, size_t size, uint32_t ocrc);
16 #define ISCSI
18 int
19 main(int ac, char **av)
21 char buf[16384];
22 int n;
23 #ifdef ISCSI
24 u_int32_t crc1 = iscsi_crc32(NULL, 0);
25 #else
26 u_int32_t crc2 = crc32(NULL, 0);
27 #endif
29 while ((n = read(0, buf, sizeof(buf))) > 0) {
30 #ifdef ISCSI
31 crc1 = iscsi_crc32_ext(buf, n, crc1);
32 #else
33 crc2 = crc32_ext(buf, n, crc2);
34 #endif
36 #ifdef ISCSI
37 printf("iscsi_crc32 %08x\n", crc1);
38 #else
39 printf("crc32 %08x\n", crc2);
40 #endif
41 return(0);