Merge branch 'vendor/OPENRESOLV' with the following changes:
[dragonfly.git] / test / debug / icrc32.c
1
2 /*
3  * cc crc32.c /usr/src/sys/libkern/{crc32.c,icrc32.c} -o ~/bin/crc32
4  */
5
6 #include <sys/types.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10
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);
15
16 #define ISCSI
17
18 int
19 main(int ac, char **av)
20 {
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
28
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
35     }
36 #ifdef ISCSI
37     printf("iscsi_crc32 %08x\n", crc1);
38 #else
39     printf("crc32 %08x\n", crc2);
40 #endif
41     return(0);
42 }