Z_U8 z_word_t;
95 typedefZ_U4 z_word_t;
106 #if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8 110 #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) 117 localz_word_t byte_swap(word)
122(word & 0xff00000000000000) >> 56 |
123(word & 0xff000000000000) >> 40 |
124(word & 0xff0000000000) >> 24 |
125(word & 0xff00000000) >> 8 |
126(word & 0xff000000) << 8 |
127(word & 0xff0000) << 24 |
128(word & 0xff00) << 40 |
132(word & 0xff000000) >> 24 |
133(word & 0xff0000) >> 8 |
134(word & 0xff00) << 8 |
141 #define POLY 0xedb88320 143 #ifdef DYNAMIC_CRC_TABLE 147 local voidmake_crc_table
OF((
void));
149 localz_word_t
FARcrc_big_table[256];
151 localz_word_t
FARcrc_braid_big_table[
W][256];
152 local voidbraid
OF((
z_crc_t[][256], z_word_t [][256],
int,
int));
156 local voidwrite_table32hi
OF((FILE *,
constz_word_t
FAR*,
int));
157 local voidwrite_table64
OF((FILE *,
constz_word_t
FAR*,
int));
169 typedef structonce_s once_t;
170 local voidonce
OF((once_t *,
void(*)(
void)));
173 #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ 174 !defined(__STDC_NO_ATOMICS__) 176 #include <stdatomic.h> 183 #define ONCE_INIT {ATOMIC_FLAG_INIT, 0} 192void (*
init)(void);
194 if(!atomic_load(&
state->done)) {
195 if(atomic_flag_test_and_set(&
state->begun))
196 while(!atomic_load(&
state->done))
200atomic_store(&
state->done, 1);
212 #define ONCE_INIT {0, 0} 216 local inttest_and_set
OF((
int volatile*));
217 local inttest_and_set(flag)
230void (*
init)(void);
232 if(!
state->done) {
233 if(test_and_set(&
state->begun))
234 while(!
state->done)
246 localonce_t made = ONCE_INIT;
273 local voidmake_crc_table()
279 for(
i= 0;
i< 256;
i++) {
281 for(j = 0; j < 8; j++)
282p = p & 1 ? (p >> 1) ^
POLY: p >> 1;
285crc_big_table[
i] = byte_swap(p);
292 for(
n= 1;
n< 32;
n++)
297braid(crc_braid_table, crc_braid_big_table,
N,
W);
308 #if !defined(W) || W != 8 309 # error Need a 64-bit integer type in order to generate crc32.h. 314z_word_t big[8][256];
316 out= fopen(
"crc32.h",
"w");
321 "/* crc32.h -- tables for rapid CRC calculation\n" 322 " * Generated automatically by crc32.c\n */\n" 324 "local const z_crc_t FAR crc_table[] = {\n" 337 "local const z_word_t FAR crc_big_table[] = {\n" 339write_table64(
out, crc_big_table, 256);
346 "#else /* W == 4 */\n" 348 "local const z_word_t FAR crc_big_table[] = {\n" 350write_table32hi(
out, crc_big_table, 256);
357 for(
n= 1;
n<= 6;
n++) {
360 "#if N == %d\n",
n);
363braid(ltl, big,
n, 8);
370 "local const z_crc_t FAR crc_braid_table[][256] = {\n");
371 for(k = 0; k < 8; k++) {
372fprintf(
out,
" {");
373write_table(
out, ltl[k], 256);
374fprintf(
out,
"}%s", k < 7 ?
",\n":
"");
379 "local const z_word_t FAR crc_braid_big_table[][256] = {\n");
380 for(k = 0; k < 8; k++) {
381fprintf(
out,
" {");
382write_table64(
out, big[k], 256);
383fprintf(
out,
"}%s", k < 7 ?
",\n":
"");
389braid(ltl, big,
n, 4);
394 "#else /* W == 4 */\n" 396 "local const z_crc_t FAR crc_braid_table[][256] = {\n");
397 for(k = 0; k < 4; k++) {
398fprintf(
out,
" {");
399write_table(
out, ltl[k], 256);
400fprintf(
out,
"}%s", k < 3 ?
",\n":
"");
405 "local const z_word_t FAR crc_braid_big_table[][256] = {\n");
406 for(k = 0; k < 4; k++) {
407fprintf(
out,
" {");
408write_table32hi(
out, big[k], 256);
409fprintf(
out,
"}%s", k < 3 ?
",\n":
"");
425 "local const z_crc_t FAR x2n_table[] = {\n" 448 for(
n= 0;
n< k;
n++)
449fprintf(
out,
"%s0x%08lx%s",
n== 0 ||
n% 5 ?
"":
" ",
450(
unsigned long)(
table[
n]),
451 n== k - 1 ?
"": (
n% 5 == 4 ?
",\n":
", "));
465 for(
n= 0;
n< k;
n++)
466fprintf(
out,
"%s0x%08lx%s",
n== 0 ||
n% 5 ?
"":
" ",
467(
unsigned long)(
table[
n] >> 32),
468 n== k - 1 ?
"": (
n% 5 == 4 ?
",\n":
", "));
485 for(
n= 0;
n< k;
n++)
486fprintf(
out,
"%s0x%016llx%s",
n== 0 ||
n% 3 ?
"":
" ",
487(
unsigned long long)(
table[
n]),
488 n== k - 1 ?
"": (
n% 3 == 2 ?
",\n":
", "));
505 local voidbraid(ltl, big,
n, w)
513 for(k = 0; k < w; k++) {
514p =
x2nmodp((
n* w + 3 - k) << 3, 0);
516big[w - 1 - k][0] = 0;
517 for(
i= 1;
i< 256;
i++) {
519big[w - 1 - k][
i] = byte_swap(q);
553 if((
a& (m - 1)) == 0)
557 b=
b& 1 ? (
b>> 1) ^
POLY:
b>> 1;
588 #ifdef DYNAMIC_CRC_TABLE 589once(&made, make_crc_table);
610 #define Z_BATCH_ZEROS 0xa10d3d0c 611 #define Z_BATCH_MIN 800 615 const unsigned char FAR*
buf;
620 constz_word_t *word;
621z_word_t val0, val1, val2;
628 #ifdef DYNAMIC_CRC_TABLE 629once(&made, make_crc_table);
639__asm__
volatile(
"crc32b %w0, %w0, %w1":
"+r"(crc) :
"r"(val));
643word = (z_word_t
const*)
buf;
650 while(num >= 3 * Z_BATCH) {
653 for(
i= 0;
i< Z_BATCH;
i++) {
655val1 = word[
i+ Z_BATCH];
656val2 = word[
i+ 2 * Z_BATCH];
657__asm__
volatile(
"crc32x %w0, %w0, %x1":
"+r"(crc) :
"r"(val0));
658__asm__
volatile(
"crc32x %w0, %w0, %x1":
"+r"(crc1) :
"r"(val1));
659__asm__
volatile(
"crc32x %w0, %w0, %x1":
"+r"(crc2) :
"r"(val2));
663crc =
multmodp(Z_BATCH_ZEROS, crc) ^ crc1;
664crc =
multmodp(Z_BATCH_ZEROS, crc) ^ crc2;
670 if(
last>= Z_BATCH_MIN) {
674 for(
i= 0;
i<
last;
i++) {
676val1 = word[
i+
last];
677val2 = word[
i+ last2];
678__asm__
volatile(
"crc32x %w0, %w0, %x1":
"+r"(crc) :
"r"(val0));
679__asm__
volatile(
"crc32x %w0, %w0, %x1":
"+r"(crc1) :
"r"(val1));
680__asm__
volatile(
"crc32x %w0, %w0, %x1":
"+r"(crc2) :
"r"(val2));
690 for(
i= 0;
i< num;
i++) {
692__asm__
volatile(
"crc32x %w0, %w0, %x1":
"+r"(crc) :
"r"(val0));
697 buf= (
const unsigned char FAR*)word;
701__asm__
volatile(
"crc32b %w0, %w0, %w1":
"+r"(crc) :
"r"(val));
705 returncrc ^ 0xffffffff;
721 for(k = 0; k <
W; k++)
730 for(k = 0; k <
W; k++)
732crc_big_table[(
data>> ((
W- 1) << 3)) & 0xff];
741 const unsigned char FAR*
buf;
747 #ifdef DYNAMIC_CRC_TABLE 748once(&made, make_crc_table);
757 if(
len>=
N*
W+
W- 1) {
759z_word_t
const*words;
770blks =
len/ (
N*
W);
771 len-= blks *
N*
W;
772words = (z_word_t
const*)
buf;
779 if(*(
unsigned char*)&endian) {
829word0 = crc0 ^ words[0];
831word1 = crc1 ^ words[1];
833word2 = crc2 ^ words[2];
835word3 = crc3 ^ words[3];
837word4 = crc4 ^ words[4];
839word5 = crc5 ^ words[5];
849crc0 = crc_braid_table[0][word0 & 0xff];
851crc1 = crc_braid_table[0][word1 & 0xff];
853crc2 = crc_braid_table[0][word2 & 0xff];
855crc3 = crc_braid_table[0][word3 & 0xff];
857crc4 = crc_braid_table[0][word4 & 0xff];
859crc5 = crc_braid_table[0][word5 & 0xff];
865 for(k = 1; k <
W; k++) {
866crc0 ^= crc_braid_table[k][(word0 >> (k << 3)) & 0xff];
868crc1 ^= crc_braid_table[k][(word1 >> (k << 3)) & 0xff];
870crc2 ^= crc_braid_table[k][(word2 >> (k << 3)) & 0xff];
872crc3 ^= crc_braid_table[k][(word3 >> (k << 3)) & 0xff];
874crc4 ^= crc_braid_table[k][(word4 >> (k << 3)) & 0xff];
876crc5 ^= crc_braid_table[k][(word5 >> (k << 3)) & 0xff];
889crc = crc_word(crc0 ^ words[0]);
891crc = crc_word(crc1 ^ words[1] ^ crc);
893crc = crc_word(crc2 ^ words[2] ^ crc);
895crc = crc_word(crc3 ^ words[3] ^ crc);
897crc = crc_word(crc4 ^ words[4] ^ crc);
899crc = crc_word(crc5 ^ words[5] ^ crc);
910z_word_t crc0, word0, comb;
912z_word_t crc1, word1;
914z_word_t crc2, word2;
916z_word_t crc3, word3;
918z_word_t crc4, word4;
920z_word_t crc5, word5;
928crc0 = byte_swap(crc);
951word0 = crc0 ^ words[0];
953word1 = crc1 ^ words[1];
955word2 = crc2 ^ words[2];
957word3 = crc3 ^ words[3];
959word4 = crc4 ^ words[4];
961word5 = crc5 ^ words[5];
971crc0 = crc_braid_big_table[0][word0 & 0xff];
973crc1 = crc_braid_big_table[0][word1 & 0xff];
975crc2 = crc_braid_big_table[0][word2 & 0xff];
977crc3 = crc_braid_big_table[0][word3 & 0xff];
979crc4 = crc_braid_big_table[0][word4 & 0xff];
981crc5 = crc_braid_big_table[0][word5 & 0xff];
987 for(k = 1; k <
W; k++) {
988crc0 ^= crc_braid_big_table[k][(word0 >> (k << 3)) & 0xff];
990crc1 ^= crc_braid_big_table[k][(word1 >> (k << 3)) & 0xff];
992crc2 ^= crc_braid_big_table[k][(word2 >> (k << 3)) & 0xff];
994crc3 ^= crc_braid_big_table[k][(word3 >> (k << 3)) & 0xff];
996crc4 ^= crc_braid_big_table[k][(word4 >> (k << 3)) & 0xff];
998crc5 ^= crc_braid_big_table[k][(word5 >> (k << 3)) & 0xff];
1011comb = crc_word_big(crc0 ^ words[0]);
1013comb = crc_word_big(crc1 ^ words[1] ^ comb);
1015comb = crc_word_big(crc2 ^ words[2] ^ comb);
1017comb = crc_word_big(crc3 ^ words[3] ^ comb);
1019comb = crc_word_big(crc4 ^ words[4] ^ comb);
1021comb = crc_word_big(crc5 ^ words[5] ^ comb);
1028crc = byte_swap(comb);
1034 buf= (
unsigned char const*)words;
1042crc = (crc >> 8) ^
crc_table[(crc ^ *
buf++) & 0xff];
1043crc = (crc >> 8) ^
crc_table[(crc ^ *
buf++) & 0xff];
1044crc = (crc >> 8) ^
crc_table[(crc ^ *
buf++) & 0xff];
1045crc = (crc >> 8) ^
crc_table[(crc ^ *
buf++) & 0xff];
1046crc = (crc >> 8) ^
crc_table[(crc ^ *
buf++) & 0xff];
1047crc = (crc >> 8) ^
crc_table[(crc ^ *
buf++) & 0xff];
1048crc = (crc >> 8) ^
crc_table[(crc ^ *
buf++) & 0xff];
1049crc = (crc >> 8) ^
crc_table[(crc ^ *
buf++) & 0xff];
1053crc = (crc >> 8) ^
crc_table[(crc ^ *
buf++) & 0xff];
1057 returncrc ^ 0xffffffff;
1065 const unsigned char FAR*
buf;
1077 #ifdef DYNAMIC_CRC_TABLE 1078once(&made, make_crc_table);
1096 #ifdef DYNAMIC_CRC_TABLE 1097once(&made, make_crc_table);
int main(int argc, const char *argv[])
std::ofstream out("events_result.xml")
main entry point for tests
static void DLIST_NAME() init(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
z_crc_t multmodp OF((z_crc_t a, z_crc_t b))
z_crc_t x2nmodp(z_off64_t n, unsigned k)
unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, z_size_t len)
const z_crc_t FAR *ZEXPORT get_crc_table()
uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2)
uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2)
uLong ZEXPORT crc32_combine_gen(z_off_t len2)
z_crc_t multmodp(z_crc_t a, z_crc_t b)
uLong ZEXPORT crc32_combine_gen64(z_off64_t len2)
uLong crc32_combine_op(uLong crc1, uLong crc2, uLong op)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
const z_crc_t FAR crc_table[]
const z_crc_t FAR x2n_table[]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4