#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
static uint32_t gf2_matrix_times(const uint32_t *mat, uint32_t vec);
static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2);
+static void crc32_combine_gen_(uint32_t *op, z_off64_t len2);
/* ========================================================================= */
static uint32_t gf2_matrix_times(const uint32_t *mat, uint32_t vec) {
}
#endif
+/* ========================================================================= */
+static void crc32_combine_gen_(uint32_t *op, z_off64_t len2)
+{
+ uint32_t row;
+ int j;
+ unsigned i;
+
+#ifdef DYNAMIC_CRC_TABLE
+ if (crc_table_empty)
+ make_crc_table();
+#endif /* DYNAMIC_CRC_TABLE */
+
+ /* if len2 is zero or negative, return the identity matrix */
+ if (len2 <= 0) {
+ row = 1;
+ for (j = 0; j < GF2_DIM; j++) {
+ op[j] = row;
+ row <<= 1;
+ }
+ return;
+ }
+
+ /* at least one bit in len2 is set -- find it, and copy the operator
+ corresponding to that position into op */
+ i = 0;
+ for (;;) {
+ if (len2 & 1) {
+ for (j = 0; j < GF2_DIM; j++)
+ op[j] = crc_comb[i][j];
+ break;
+ }
+ len2 >>= 1;
+ i = (i + 1) % GF2_DIM;
+ }
+
+ /* for each remaining bit set in len2 (if any), multiply op by the operator
+ corresponding to that position */
+ for (;;) {
+ len2 >>= 1;
+ i = (i + 1) % GF2_DIM;
+ if (len2 == 0)
+ break;
+ if (len2 & 1)
+ for (j = 0; j < GF2_DIM; j++)
+ op[j] = gf2_matrix_times(crc_comb[i], op[j]);
+ }
+}
+
+/* ========================================================================= */
+void ZEXPORT PREFIX(crc32_combine_gen)(uint32_t *op, z_off_t len2)
+{
+ crc32_combine_gen_(op, len2);
+}
+
+void ZEXPORT PREFIX(crc32_combine_gen64)(uint32_t *op, z_off64_t len2)
+{
+ crc32_combine_gen_(op, len2);
+}
+
+/* ========================================================================= */
+uint32_t ZEXPORT PREFIX(crc32_combine_op)(uint32_t crc1, uint32_t crc2, const uint32_t *op)
+{
+ return gf2_matrix_times(op, crc1) ^ crc2;
+}
len2.
*/
+/*
+ZEXTERN void ZEXPORT zng_crc32_combine_gen(uint32_t op[32], z_off_t len2);
+
+ Generate the operator op corresponding to length len2, to be used with
+ crc32_combine_op(). op must have room for 32 uint32_t values. (32 is the
+ number of bits in the CRC.)
+*/
+
+ZEXTERN uint32_t ZEXPORT zng_crc32_combine_op(uint32_t crc1, uint32_t crc2,
+ const uint32_t *op);
+/*
+ Give the same result as crc32_combine(), using op in place of len2. op is
+ is generated from len2 by crc32_combine_gen(). This will be faster than
+ crc32_combine() if the generated op is used many times.
+*/
/* various hacks, don't look :) */
#ifdef Z_LARGE64
ZEXTERN uint32_t ZEXPORT zng_adler32_combine64(uint32_t, uint32_t, z_off64_t);
ZEXTERN uint32_t ZEXPORT zng_crc32_combine64(uint32_t, uint32_t, z_off64_t);
+ ZEXTERN void ZEXPORT zng_crc32_combine_gen64(uint32_t *op, z_off64_t);
#endif
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
# define zng_adler32_combine zng_adler32_combine64
# define zng_crc32_combine zng_crc32_combine64
+# define zng_crc32_combine_gen zng_crc32_combine_gen64
# ifndef Z_LARGE64
ZEXTERN uint32_t ZEXPORT zng_adler32_combine64(uint32_t, uint32_t, z_off_t);
ZEXTERN uint32_t ZEXPORT zng_crc32_combine64(uint32_t, uint32_t, z_off_t);
+ ZEXTERN void ZEXPORT zng_crc32_combine_gen64(uint32_t *op, z_off64_t);
# endif
#else
ZEXTERN uint32_t ZEXPORT zng_adler32_combine(uint32_t, uint32_t, z_off_t);
ZEXTERN uint32_t ZEXPORT zng_crc32_combine(uint32_t, uint32_t, z_off_t);
+ ZEXTERN void ZEXPORT zng_crc32_combine_gen(uint32_t *op, z_off_t);
#endif
zng_crc32;
zng_crc32_combine;
zng_crc32_combine64;
+ zng_crc32_combine_gen;
+ zng_crc32_combine_op;
zng_crc32_z;
zng_deflate;
zng_deflateBound;
len2.
*/
+/*
+ZEXTERN void ZEXPORT crc32_combine_gen(uint32_t op[32], z_off_t len2);
+
+ Generate the operator op corresponding to length len2, to be used with
+ crc32_combine_op(). op must have room for 32 z_crc_t values. (32 is the
+ number of bits in the CRC.)
+*/
+
+ZEXTERN uint32_t ZEXPORT crc32_combine_op(uint32_t crc1, uint32_t crc2,
+ const uint32_t *op);
+/*
+ Give the same result as crc32_combine(), using op in place of len2. op is
+ is generated from len2 by crc32_combine_gen(). This will be faster than
+ crc32_combine() if the generated op is used many times.
+*/
+
/* various hacks, don't look :) */
#ifdef Z_LARGE64
ZEXTERN uint32_t ZEXPORT adler32_combine64(uint32_t, uint32_t, z_off64_t);
ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off64_t);
+ ZEXTERN void ZEXPORT crc32_combine_gen64(uint32_t *op, z_off64_t);
#endif
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
# define adler32_combine adler32_combine64
# define crc32_combine crc32_combine64
+# define crc32_combine_gen crc32_combine_gen64
# ifndef Z_LARGE64
ZEXTERN uint32_t ZEXPORT adler32_combine64(uint32_t, uint32_t, z_off_t);
ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off_t);
+ ZEXTERN void ZEXPORT crc32_combine_gen64(uint32_t *op, z_off64_t);
# endif
#else
ZEXTERN uint32_t ZEXPORT adler32_combine(uint32_t, uint32_t, z_off_t);
ZEXTERN uint32_t ZEXPORT crc32_combine(uint32_t, uint32_t, z_off_t);
+ ZEXTERN void ZEXPORT crc32_combine_gen(uint32_t *op, z_off_t);
#endif
deflateGetDictionary;
adler32_z;
crc32_z;
+ crc32_combine_gen;
+ crc32_combine_op;
} ZLIB_1.2.7.1;