summaryrefslogtreecommitdiff
path: root/crc32.c
diff options
context:
space:
mode:
authorDaniel Axtens <dja@axtens.net>2015-05-11 23:29:29 +1000
committerHans Kristian Rosbach <hk-git@circlestorm.org>2015-05-13 14:31:52 +0200
commit4db4cfdb5badc8860f7410732b12c45216d709b3 (patch)
tree2b7701b1024cb1bf8f6f600d7acb5adcd9c54881 /crc32.c
parent08cef610586534681a6998091e284fe37b9b9289 (diff)
Kill z_crc_t
Signed-off-by: Daniel Axtens <dja@axtens.net> Conflicts: crc32.c
Diffstat (limited to 'crc32.c')
-rw-r--r--crc32.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/crc32.c b/crc32.c
index 338e9dc..3dd4c7d 100644
--- a/crc32.c
+++ b/crc32.c
@@ -59,10 +59,10 @@ static uint32_t crc32_combine_ (uint32_t crc1, uint32_t crc2, z_off64_t len2);
#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:
@@ -92,9 +92,9 @@ static void make_crc_table (void);
*/
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};
@@ -108,11 +108,11 @@ static void make_crc_table()
/* 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;
@@ -147,7 +147,7 @@ static void make_crc_table()
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++) {
@@ -161,7 +161,7 @@ static void make_crc_table()
}
#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;
@@ -182,13 +182,13 @@ static void write_table(FILE *out, const z_crc_t *table)
/* =========================================================================
* 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;
}
/* ========================================================================= */
@@ -244,17 +244,17 @@ uint32_t ZEXPORT crc32(uint32_t crc, const unsigned char *buf, uInt len)
/* ========================================================================= */
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) {
@@ -287,17 +287,17 @@ static uint32_t crc32_little(uint32_t crc, const unsigned char *buf, unsigned le
/* ========================================================================= */
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