diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/crc32.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/lib/crc32.c b/lib/crc32.c index df41009112..db08b65734 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -8,21 +8,15 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -#ifndef USE_HOSTCC /* Shut down "ANSI does not permit..." warnings */ +#ifdef __U_BOOT__ /* Shut down "ANSI does not permit..." warnings */ #include <common.h> /* to get command definitions like CFG_CMD_JFFS2 */ #endif -#include "zlib.h" - -#define local static -#define ZEXPORT /* empty */ -unsigned long crc32 (unsigned long, const unsigned char *, unsigned int); - #ifdef CONFIG_DYNAMIC_CRC_TABLE -local int crc_table_empty = 1; -local uLongf crc_table[256]; -local void make_crc_table OF((void)); +static int crc_table_empty = 1; +static ulong crc_table[256]; +static void make_crc_table(void); /* Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: @@ -48,22 +42,22 @@ local void make_crc_table OF((void)); the information needed to generate CRC's on data a byte at a time for all combinations of CRC register values and incoming bytes. */ -local void make_crc_table() +static void make_crc_table() { - uLong c; + ulong c; int n, k; - uLong poly; /* polynomial exclusive-or pattern */ + ulong poly; /* polynomial exclusive-or pattern */ /* terms of polynomial defining this crc (except x^32): */ - static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + static const char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; /* make exclusive-or pattern from polynomial (0xedb88320L) */ poly = 0L; - for (n = 0; n < sizeof(p)/sizeof(Byte); n++) + for (n = 0; n < sizeof(p)/sizeof(char); n++) poly |= 1L << (31 - p[n]); for (n = 0; n < 256; n++) { - c = (uLong)n; + c = (ulong)n; for (k = 0; k < 8; k++) c = c & 1 ? poly ^ (c >> 1) : c >> 1; crc_table[n] = c; @@ -74,7 +68,7 @@ local void make_crc_table() /* ======================================================================== * Table of CRC-32's of all single-byte values (made by make_crc_table) */ -local const uLongf crc_table[256] = { +static const ulong crc_table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, @@ -138,10 +132,7 @@ local const uLongf crc_table[256] = { #define DO8(buf) DO4(buf); DO4(buf); /* ========================================================================= */ -uLong ZEXPORT crc32(crc, buf, len) - uLong crc; - const Bytef *buf; - uInt len; +ulong crc32(ulong crc, const unsigned char *buf, uint len) { #ifdef CONFIG_DYNAMIC_CRC_TABLE if (crc_table_empty) @@ -165,7 +156,7 @@ uLong ZEXPORT crc32(crc, buf, len) /* No ones complement version. JFFS2 (and other things ?) * don't use ones compliment in their CRC calculations. */ -uLong ZEXPORT crc32_no_comp(uLong crc, const Bytef *buf, uInt len) +uLong crc32_no_comp(uLong crc, const Bytef *buf, uint len) { #ifdef CONFIG_DYNAMIC_CRC_TABLE if (crc_table_empty) |