diff options
author | jmadill <jmadill@chromium.org> | 2016-06-20 06:58:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-20 14:01:19 +0000 |
commit | bf2aebeacfc84bf69ff964edbf212ec3aed6430c (patch) | |
tree | dfa65fc6e4ed637adcd0a4e9a13d353eef01f543 /adler32.c | |
parent | 90f7dad71a47e992425d7deda7970643990288f3 (diff) | |
download | zlib-bf2aebeacfc84bf69ff964edbf212ec3aed6430c.tar.gz |
Revert of Update Zlib to version 1.2.8 (patchset #10 id:220001 of https://codereview.chromium.org/1955383002/ )
Reason for revert:
Broke the Windows Debug GPU FYI builder:
https://build.chromium.org/p/chromium.gpu.fyi/builders/GPU%20Win%20Builder%20%28dbg%29/builds/41421
fx_zlib.gzlib.obj : error LNK2005: _gzopen_w already defined in zlib.gzlib.obj
initial\chrome.dll : fatal error LNK1169: one or more multiply defined symbols found
Possibly because they use shared components with a GYP build.
Original issue's description:
> Update Zlib to version 1.2.8
>
> merge the latest open source zlib into chromium external projects
>
> Version 1.2.8 fixes a very rare bug in decompression. All users are encouraged to upgrade immediately. Version 1.2.8 also has these improvements:
> - Add new inflateGetDictionary() function
> - Fix bug where gzopen() immediately followed by gzclose() would write an empty file instead of an empty gzip stream.
> - Fix bug in gzclose() when gzwrite() runs out of memory
> Version 1.2.7 has many portability improvements over 1.2.6, and has these enhancements:
> - Fix bug in gzclose_w() when gzwrite() fails to allocate memory
> - Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen()
> - Add gzopen_w() in Windows for wide character path names
> - Fix type mismatch between get_crc_table() and crc_table
> Version 1.2.6 has many changes over 1.2.5, including these improvements:
> - gzread() can now read a file that is being written concurrently
> - gzgetc() is now a macro for increased speed
> - Added a 'T' option to gzopen() for transparent writing (no compression)
> - Added deflatePending() to return the amount of pending output
> - Allow deflateSetDictionary() and inflateSetDictionary() at any time in raw mode
> - deflatePrime() can now insert bits in the middle of the stream
> - ./configure now creates a configure.log file with all of the results
> - Added a ./configure --solo option to compile zlib with no dependency on any libraries
> - Fixed a problem with large file support macros
> - Fixed a bug in contrib/puff
> - Many portability improvements
>
> BUG=610615
> R=agl@chromium.org
> R=gavinp@chromium.org
>
> Committed: https://crrev.com/a50849ae9ba1b2fad47905db521463b3bf085883
> Cr-Commit-Position: refs/heads/master@{#400647}
TBR=agl@chromium.org,gavinp@chromium.org,khasim.mohammed@linaro.org,jiadong.zhu@linaro.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=610615
Review-Url: https://codereview.chromium.org/2079313002
Cr-Original-Commit-Position: refs/heads/master@{#400670}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 43770253ccc0425c4edde966e56b3e68955cc4d3
Diffstat (limited to 'adler32.c')
-rw-r--r-- | adler32.c | 68 |
1 files changed, 29 insertions, 39 deletions
@@ -1,5 +1,5 @@ /* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2011 Mark Adler + * Copyright (C) 1995-2007 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,9 +9,9 @@ #define local static -local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); -#define BASE 65521 /* largest prime smaller than 65536 */ +#define BASE 65521UL /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ @@ -21,44 +21,39 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); #define DO16(buf) DO8(buf,0); DO8(buf,8); -/* use NO_DIVIDE if your processor does not do division in hardware -- - try it both ways to see which is faster */ +/* use NO_DIVIDE if your processor does not do division in hardware */ #ifdef NO_DIVIDE -/* note that this assumes BASE is 65521, where 65536 % 65521 == 15 - (thank you to John Reiser for pointing this out) */ -# define CHOP(a) \ - do { \ - unsigned long tmp = a >> 16; \ - a &= 0xffffUL; \ - a += (tmp << 4) - tmp; \ - } while (0) -# define MOD28(a) \ +# define MOD(a) \ do { \ - CHOP(a); \ + if (a >= (BASE << 16)) a -= (BASE << 16); \ + if (a >= (BASE << 15)) a -= (BASE << 15); \ + if (a >= (BASE << 14)) a -= (BASE << 14); \ + if (a >= (BASE << 13)) a -= (BASE << 13); \ + if (a >= (BASE << 12)) a -= (BASE << 12); \ + if (a >= (BASE << 11)) a -= (BASE << 11); \ + if (a >= (BASE << 10)) a -= (BASE << 10); \ + if (a >= (BASE << 9)) a -= (BASE << 9); \ + if (a >= (BASE << 8)) a -= (BASE << 8); \ + if (a >= (BASE << 7)) a -= (BASE << 7); \ + if (a >= (BASE << 6)) a -= (BASE << 6); \ + if (a >= (BASE << 5)) a -= (BASE << 5); \ + if (a >= (BASE << 4)) a -= (BASE << 4); \ + if (a >= (BASE << 3)) a -= (BASE << 3); \ + if (a >= (BASE << 2)) a -= (BASE << 2); \ + if (a >= (BASE << 1)) a -= (BASE << 1); \ if (a >= BASE) a -= BASE; \ } while (0) -# define MOD(a) \ +# define MOD4(a) \ do { \ - CHOP(a); \ - MOD28(a); \ - } while (0) -# define MOD63(a) \ - do { /* this assumes a is not negative */ \ - z_off64_t tmp = a >> 32; \ - a &= 0xffffffffL; \ - a += (tmp << 8) - (tmp << 5) + tmp; \ - tmp = a >> 16; \ - a &= 0xffffL; \ - a += (tmp << 4) - tmp; \ - tmp = a >> 16; \ - a &= 0xffffL; \ - a += (tmp << 4) - tmp; \ + if (a >= (BASE << 4)) a -= (BASE << 4); \ + if (a >= (BASE << 3)) a -= (BASE << 3); \ + if (a >= (BASE << 2)) a -= (BASE << 2); \ + if (a >= (BASE << 1)) a -= (BASE << 1); \ if (a >= BASE) a -= BASE; \ } while (0) #else # define MOD(a) a %= BASE -# define MOD28(a) a %= BASE -# define MOD63(a) a %= BASE +# define MOD4(a) a %= BASE #endif /* ========================================================================= */ @@ -97,7 +92,7 @@ uLong ZEXPORT adler32(adler, buf, len) } if (adler >= BASE) adler -= BASE; - MOD28(sum2); /* only added so many BASE's */ + MOD4(sum2); /* only added so many BASE's */ return adler | (sum2 << 16); } @@ -142,13 +137,8 @@ local uLong adler32_combine_(adler1, adler2, len2) unsigned long sum2; unsigned rem; - /* for negative len, return invalid adler32 as a clue for debugging */ - if (len2 < 0) - return 0xffffffffUL; - /* the derivation of this formula is left as an exercise for the reader */ - MOD63(len2); /* assumes len2 >= 0 */ - rem = (unsigned)len2; + rem = (unsigned)(len2 % BASE); sum1 = adler1 & 0xffff; sum2 = rem * sum1; MOD(sum2); |