#ifdef DYNAMIC_CRC_TABLE
static volatile int crc_table_empty = 1;
-static z_crc_t crc_table[8][256];
+static uint32_t crc_table[8][256];
static void make_crc_table (void);
#ifdef MAKECRCH
- static void write_table (FILE *, const z_crc_t *);
+ static void write_table (FILE *, const uint32_t *);
#endif /* MAKECRCH */
/*
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
*/
static void make_crc_table()
{
- z_crc_t c;
+ uint32_t c;
int n, k;
- z_crc_t poly; /* polynomial exclusive-or pattern */
+ uint32_t poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */
static volatile int first = 1; /* flag to limit concurrent making */
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* make exclusive-or pattern from polynomial (0xedb88320) */
poly = 0;
for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
- poly |= (z_crc_t)1 << (31 - p[n]);
+ poly |= (uint32_t)1 << (31 - p[n]);
/* generate a crc for every 8-bit value */
for (n = 0; n < 256; n++) {
- c = (z_crc_t)n;
+ c = (uint32_t)n;
for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
crc_table[0][n] = c;
if (out == NULL) return;
fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
- fprintf(out, "static const z_crc_t ");
+ fprintf(out, "static const uint32_t ");
fprintf(out, "crc_table[8][256] =\n{\n {\n");
write_table(out, crc_table[0]);
for (k = 1; k < 8; k++) {
}
#ifdef MAKECRCH
-static void write_table(FILE *out, const z_crc_t *table)
+static void write_table(FILE *out, const uint32_t *table)
{
int n;
/* =========================================================================
* This function can be used by asm versions of crc32()
*/
-const z_crc_t * ZEXPORT get_crc_table()
+const uint32_t * ZEXPORT get_crc_table()
{
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
- return (const z_crc_t *)crc_table;
+ return (const uint32_t *)crc_table;
}
/* ========================================================================= */
/* ========================================================================= */
static uint32_t crc32_little(uint32_t crc, const unsigned char *buf, unsigned len)
{
- register z_crc_t c;
- register const z_crc_t *buf4;
+ register uint32_t c;
+ register const uint32_t *buf4;
- c = (z_crc_t)crc;
+ c = (uint32_t)crc;
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
len--;
}
- buf4 = (const z_crc_t *)(const void *)buf;
+ buf4 = (const uint32_t *)(const void *)buf;
#ifndef UNROLL_LESS
while (len >= 32) {
/* ========================================================================= */
static uint32_t crc32_big(uint32_t crc, const unsigned char *buf, unsigned len)
{
- register z_crc_t c;
- register const z_crc_t *buf4;
+ register uint32_t c;
+ register const uint32_t *buf4;
- c = ZSWAP32((z_crc_t)crc);
+ c = ZSWAP32((uint32_t)crc);
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
len--;
}
- buf4 = (const z_crc_t *)(const void *)buf;
+ buf4 = (const uint32_t *)(const void *)buf;
buf4--;
#ifndef UNROLL_LESS