Skip to content

Commit

Permalink
some old changes
Browse files Browse the repository at this point in the history
Signed-off-by: Slice <sergey.slice@gmail.com>
  • Loading branch information
SergeySlice committed Sep 5, 2023
1 parent 3157e84 commit df32654
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 65 deletions.
25 changes: 5 additions & 20 deletions Library/OcCompressionLib/zlib/adler32.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#endif

/* ========================================================================= */
uLong ZEXPORT adler32_z(adler, buf, len)
uLong adler;
const Bytef *buf;
z_size_t len;
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len)
{
unsigned long sum2;
unsigned n;
Expand Down Expand Up @@ -131,19 +128,13 @@ uLong ZEXPORT adler32_z(adler, buf, len)
}

/* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len)
uLong adler;
const Bytef *buf;
uInt len;
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
{
return adler32_z(adler, buf, len);
}

/* ========================================================================= */
local uLong adler32_combine_(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off64_t len2;
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2)
{
unsigned long sum1;
unsigned long sum2;
Expand All @@ -169,18 +160,12 @@ local uLong adler32_combine_(adler1, adler2, len2)
}

/* ========================================================================= */
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off_t len2;
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2)
{
return adler32_combine_(adler1, adler2, len2);
}

uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off64_t len2;
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2)
{
return adler32_combine_(adler1, adler2, len2);
}
16 changes: 3 additions & 13 deletions Library/OcCompressionLib/zlib/compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int level;
int ZEXPORT compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
{
z_stream stream;
int err;
Expand Down Expand Up @@ -65,11 +60,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)

/* ===========================================================================
*/
int ZEXPORT compress (dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int ZEXPORT compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
Expand All @@ -78,8 +69,7 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
uLong ZEXPORT compressBound (sourceLen)
uLong sourceLen;
uLong ZEXPORT compressBound (uLong sourceLen)
{
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
(sourceLen >> 25) + 13;
Expand Down
43 changes: 11 additions & 32 deletions Library/OcCompressionLib/zlib/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,7 @@ local void braid(ltl, big, n, w)
Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
reflected. For speed, this requires that a not be zero.
*/
local z_crc_t multmodp(a, b)
z_crc_t a;
z_crc_t b;
local z_crc_t multmodp(z_crc_t a, z_crc_t b)
{
z_crc_t m, p;

Expand All @@ -533,9 +531,7 @@ local z_crc_t multmodp(a, b)
Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
initialized.
*/
local z_crc_t x2nmodp(n, k)
z_off64_t n;
unsigned k;
local z_crc_t x2nmodp(z_off64_t n, unsigned k)
{
z_crc_t p;

Expand All @@ -557,8 +553,7 @@ local z_crc_t x2nmodp(n, k)
instruction, if one is available. This assumes that word_t is either 32 bits
or 64 bits.
*/
local z_word_t byte_swap(word)
z_word_t word;
local z_word_t byte_swap(z_word_t word)
{
#if W == 8
return
Expand All @@ -584,17 +579,15 @@ local z_word_t byte_swap(word)
least-significant byte of the word as the first byte of data, without any pre
or post conditioning. This is used to combine the CRCs of each braid.
*/
local z_crc_t crc_word(data)
z_word_t data;
local z_crc_t crc_word(z_word_t data)
{
int k;
for (k = 0; k < W; k++)
data = (data >> 8) ^ crc_table[data & 0xff];
return (z_crc_t)data;
}

local z_word_t crc_word_big(data)
z_word_t data;
local z_word_t crc_word_big(z_word_t data)
{
int k;
for (k = 0; k < W; k++)
Expand Down Expand Up @@ -1058,19 +1051,13 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
#endif

/* ========================================================================= */
unsigned long ZEXPORT crc32(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
uInt len;
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
{
return crc32_z(crc, buf, len);
}

/* ========================================================================= */
uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
uLong crc1;
uLong crc2;
z_off64_t len2;
uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2)
{
#ifdef DYNAMIC_CRC_TABLE
once(&made, make_crc_table);
Expand All @@ -1079,17 +1066,13 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
}

/* ========================================================================= */
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
uLong crc1;
uLong crc2;
z_off_t len2;
uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2)
{
return crc32_combine64(crc1, crc2, len2);
}

/* ========================================================================= */
uLong ZEXPORT crc32_combine_gen64(len2)
z_off64_t len2;
uLong ZEXPORT crc32_combine_gen64(z_off64_t len2)
{
#ifdef DYNAMIC_CRC_TABLE
once(&made, make_crc_table);
Expand All @@ -1098,17 +1081,13 @@ uLong ZEXPORT crc32_combine_gen64(len2)
}

/* ========================================================================= */
uLong ZEXPORT crc32_combine_gen(len2)
z_off_t len2;
uLong ZEXPORT crc32_combine_gen(z_off_t len2)
{
return crc32_combine_gen64(len2);
}

/* ========================================================================= */
uLong crc32_combine_op(crc1, crc2, op)
uLong crc1;
uLong crc2;
uLong op;
uLong crc32_combine_op(uLong crc1, uLong crc2, uLong op)
{
return multmodp(op, crc1) ^ crc2;
}

0 comments on commit df32654

Please sign in to comment.