| Index: third_party/zlib/google.patch
|
| diff --git a/third_party/zlib/google.patch b/third_party/zlib/google.patch
|
| index 3818b11745073fb8afcf71719c84575fda690983..609fb1970fec0d77c4cf40ebf1106255e1cbe51c 100644
|
| --- a/third_party/zlib/google.patch
|
| +++ b/third_party/zlib/google.patch
|
| @@ -1,192 +1,904 @@
|
| -diff -ru zlib-1.2.5/gzlib.c zlib/gzlib.c
|
| ---- zlib-1.2.5/gzlib.c
|
| -+++ zlib/gzlib.c
|
| -@@ -5,7 +5,9 @@
|
| +diff -ru zlib-1.2.8/contrib/minizip/ioapi.h zlib/contrib/minizip/ioapi.h
|
| +--- zlib-1.2.8/contrib/minizip/ioapi.h 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/contrib/minizip/ioapi.h 2016-05-13 17:32:21.510780073 +0800
|
| +@@ -43,7 +43,7 @@
|
|
|
| - #include "gzguts.h"
|
| + #include <stdio.h>
|
| + #include <stdlib.h>
|
| +-#include "zlib.h"
|
| ++#include "third_party/zlib/zlib.h"
|
|
|
| --#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
| -+#if defined(_WIN32)
|
| -+# define LSEEK (z_off64_t)_lseeki64
|
| -+#elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
| - # define LSEEK lseek64
|
| + #if defined(USE_FILE32API)
|
| + #define fopen64 fopen
|
| +diff -ru zlib-1.2.8/contrib/minizip/mztools.c zlib/contrib/minizip/mztools.c
|
| +--- zlib-1.2.8/contrib/minizip/mztools.c 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/contrib/minizip/mztools.c 2016-05-13 17:32:21.510780073 +0800
|
| +@@ -8,7 +8,7 @@
|
| + #include <stdio.h>
|
| + #include <stdlib.h>
|
| + #include <string.h>
|
| +-#include "zlib.h"
|
| ++#include "third_party/zlib/zlib.h"
|
| + #include "unzip.h"
|
| +
|
| + #define READ_8(adr) ((unsigned char)*(adr))
|
| +diff -ru zlib-1.2.8/contrib/minizip/mztools.h zlib/contrib/minizip/mztools.h
|
| +--- zlib-1.2.8/contrib/minizip/mztools.h 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/contrib/minizip/mztools.h 2016-05-13 17:32:21.510780073 +0800
|
| +@@ -12,7 +12,7 @@
|
| + #endif
|
| +
|
| + #ifndef _ZLIB_H
|
| +-#include "zlib.h"
|
| ++#include "third_party/zlib/zlib.h"
|
| + #endif
|
| +
|
| + #include "unzip.h"
|
| +diff -ru zlib-1.2.8/contrib/minizip/unzip.c zlib/contrib/minizip/unzip.c
|
| +--- zlib-1.2.8/contrib/minizip/unzip.c 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/contrib/minizip/unzip.c 2016-05-13 17:32:21.510780073 +0800
|
| +@@ -72,7 +72,7 @@
|
| + #define NOUNCRYPT
|
| + #endif
|
| +
|
| +-#include "zlib.h"
|
| ++#include "third_party/zlib/zlib.h"
|
| + #include "unzip.h"
|
| +
|
| + #ifdef STDC
|
| +@@ -1705,11 +1705,6 @@
|
| +
|
| + pfile_in_zip_read_info->stream.avail_out = (uInt)len;
|
| +
|
| +- if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
|
| +- (!(pfile_in_zip_read_info->raw)))
|
| +- pfile_in_zip_read_info->stream.avail_out =
|
| +- (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
|
| +-
|
| + if ((len>pfile_in_zip_read_info->rest_read_compressed+
|
| + pfile_in_zip_read_info->stream.avail_in) &&
|
| + (pfile_in_zip_read_info->raw))
|
| +diff -ru zlib-1.2.8/contrib/minizip/unzip.h zlib/contrib/minizip/unzip.h
|
| +--- zlib-1.2.8/contrib/minizip/unzip.h 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/contrib/minizip/unzip.h 2016-05-13 17:32:21.510780073 +0800
|
| +@@ -48,7 +48,7 @@
|
| + #endif
|
| +
|
| + #ifndef _ZLIB_H
|
| +-#include "zlib.h"
|
| ++#include "third_party/zlib/zlib.h"
|
| + #endif
|
| +
|
| + #ifndef _ZLIBIOAPI_H
|
| +diff -ru zlib-1.2.8/contrib/minizip/zip.c zlib/contrib/minizip/zip.c
|
| +--- zlib-1.2.8/contrib/minizip/zip.c 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/contrib/minizip/zip.c 2016-05-13 17:32:21.510780073 +0800
|
| +@@ -26,7 +26,7 @@
|
| + #include <stdlib.h>
|
| + #include <string.h>
|
| + #include <time.h>
|
| +-#include "zlib.h"
|
| ++#include "third_party/zlib/zlib.h"
|
| + #include "zip.h"
|
| +
|
| + #ifdef STDC
|
| +diff -ru zlib-1.2.8/contrib/minizip/zip.h zlib/contrib/minizip/zip.h
|
| +--- zlib-1.2.8/contrib/minizip/zip.h 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/contrib/minizip/zip.h 2016-05-13 17:32:21.510780073 +0800
|
| +@@ -47,7 +47,7 @@
|
| + //#define HAVE_BZIP2
|
| +
|
| + #ifndef _ZLIB_H
|
| +-#include "zlib.h"
|
| ++#include "third_party/zlib/zlib.h"
|
| + #endif
|
| +
|
| + #ifndef _ZLIBIOAPI_H
|
| +diff -ru zlib-1.2.8/crc32.c zlib/crc32.c
|
| +--- zlib-1.2.8/crc32.c 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/crc32.c 2016-05-13 17:32:21.454780493 +0800
|
| +@@ -28,6 +28,8 @@
|
| + # endif /* !DYNAMIC_CRC_TABLE */
|
| + #endif /* MAKECRCH */
|
| +
|
| ++#include "deflate.h"
|
| ++#include "x86.h"
|
| + #include "zutil.h" /* for STDC and FAR definitions */
|
| +
|
| + #define local static
|
| +@@ -423,3 +425,28 @@
|
| + {
|
| + return crc32_combine_(crc1, crc2, len2);
|
| + }
|
| ++
|
| ++ZLIB_INTERNAL void crc_reset(deflate_state *const s)
|
| ++{
|
| ++ if (x86_cpu_enable_simd) {
|
| ++ crc_fold_init(s);
|
| ++ return;
|
| ++ }
|
| ++ s->strm->adler = crc32(0L, Z_NULL, 0);
|
| ++}
|
| ++
|
| ++ZLIB_INTERNAL void crc_finalize(deflate_state *const s)
|
| ++{
|
| ++ if (x86_cpu_enable_simd)
|
| ++ s->strm->adler = crc_fold_512to32(s);
|
| ++}
|
| ++
|
| ++ZLIB_INTERNAL void copy_with_crc(z_streamp strm, Bytef *dst, long size)
|
| ++{
|
| ++ if (x86_cpu_enable_simd) {
|
| ++ crc_fold_copy(strm->state, dst, strm->next_in, size);
|
| ++ return;
|
| ++ }
|
| ++ zmemcpy(dst, strm->next_in, size);
|
| ++ strm->adler = crc32(strm->adler, dst, size);
|
| ++}
|
| +diff -ru zlib-1.2.8/deflate.c zlib/deflate.c
|
| +--- zlib-1.2.8/deflate.c 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/deflate.c 2016-05-13 17:32:21.454780493 +0800
|
| +@@ -49,7 +49,10 @@
|
| +
|
| + /* @(#) $Id$ */
|
| +
|
| ++#include <assert.h>
|
| ++
|
| + #include "deflate.h"
|
| ++#include "x86.h"
|
| +
|
| + const char deflate_copyright[] =
|
| + " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";
|
| +@@ -70,26 +73,27 @@
|
| + finish_done /* finish done, accept no more input or output */
|
| + } block_state;
|
| +
|
| +-typedef block_state (*compress_func) OF((deflate_state *s, int flush));
|
| ++typedef block_state (*compress_func) OF((deflate_state *s, int flush,
|
| ++ int clas));
|
| + /* Compression function. Returns the block state after the call. */
|
| +
|
| + local void fill_window OF((deflate_state *s));
|
| +-local block_state deflate_stored OF((deflate_state *s, int flush));
|
| +-local block_state deflate_fast OF((deflate_state *s, int flush));
|
| ++local block_state deflate_stored OF((deflate_state *s, int flush, int clas));
|
| ++local block_state deflate_fast OF((deflate_state *s, int flush, int clas));
|
| + #ifndef FASTEST
|
| +-local block_state deflate_slow OF((deflate_state *s, int flush));
|
| ++local block_state deflate_slow OF((deflate_state *s, int flush, int clas));
|
| + #endif
|
| + local block_state deflate_rle OF((deflate_state *s, int flush));
|
| + local block_state deflate_huff OF((deflate_state *s, int flush));
|
| + local void lm_init OF((deflate_state *s));
|
| + local void putShortMSB OF((deflate_state *s, uInt b));
|
| + local void flush_pending OF((z_streamp strm));
|
| +-local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
| ++
|
| + #ifdef ASMV
|
| + void match_init OF((void)); /* asm code initialization */
|
| +- uInt longest_match OF((deflate_state *s, IPos cur_match));
|
| ++ uInt longest_match OF((deflate_state *s, IPos cur_match, int clas));
|
| #else
|
| - # define LSEEK lseek
|
| -diff -ru zlib-1.2.5/mozzconf.h zlib/mozzconf.h
|
| ---- zlib-1.2.5/mozzconf.h 2011-12-15 18:10:49.000000000 +0800
|
| -+++ zlib/mozzconf.h 2011-12-16 16:08:00.000000000 +0800
|
| -@@ -0,0 +1,168 @@
|
| -+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
| -+/* ***** BEGIN LICENSE BLOCK *****
|
| -+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
| -+ *
|
| -+ * The contents of this file are subject to the Mozilla Public License Version
|
| -+ * 1.1 (the "License"); you may not use this file except in compliance with
|
| -+ * the License. You may obtain a copy of the License at
|
| -+ * http://www.mozilla.org/MPL/
|
| -+ *
|
| -+ * Software distributed under the License is distributed on an "AS IS" basis,
|
| -+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
| -+ * for the specific language governing rights and limitations under the
|
| -+ * License.
|
| -+ *
|
| -+ * The Original Code is the mozilla zlib configuration.
|
| -+ *
|
| -+ * The Initial Developer of the Original Code is IBM Corporation.
|
| -+ * Portions created by the Initial Developer are Copyright (C) 2004
|
| -+ * the Initial Developer. All Rights Reserved.
|
| -+ *
|
| -+ * Contributor(s):
|
| -+ *
|
| -+ * Alternatively, the contents of this file may be used under the terms of
|
| -+ * either of the GNU General Public License Version 2 or later (the "GPL"),
|
| -+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
| -+ * in which case the provisions of the GPL or the LGPL are applicable instead
|
| -+ * of those above. If you wish to allow use of your version of this file only
|
| -+ * under the terms of either the GPL or the LGPL, and not to allow others to
|
| -+ * use your version of this file under the terms of the MPL, indicate your
|
| -+ * decision by deleting the provisions above and replace them with the notice
|
| -+ * and other provisions required by the GPL or the LGPL. If you do not delete
|
| -+ * the provisions above, a recipient may use your version of this file under
|
| -+ * the terms of any one of the MPL, the GPL or the LGPL.
|
| -+ *
|
| -+ * ***** END LICENSE BLOCK ***** */
|
| +-local uInt longest_match OF((deflate_state *s, IPos cur_match));
|
| ++local uInt longest_match OF((deflate_state *s, IPos cur_match, int clas));
|
| + #endif
|
| +
|
| + #ifdef DEBUG
|
| +@@ -97,6 +101,23 @@
|
| + int length));
|
| + #endif
|
| +
|
| ++/* For fill_window_sse.c to use */
|
| ++ZLIB_INTERNAL int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
| +
|
| -+#ifndef MOZZCONF_H
|
| -+#define MOZZCONF_H
|
| ++/* From crc32.c */
|
| ++extern void ZLIB_INTERNAL crc_reset(deflate_state *const s);
|
| ++extern void ZLIB_INTERNAL crc_finalize(deflate_state *const s);
|
| ++extern void ZLIB_INTERNAL copy_with_crc(z_streamp strm, Bytef *dst, long size);
|
| +
|
| -+#if defined(XP_WIN) && defined(ZLIB_DLL) && !defined(MOZ_ENABLE_LIBXUL)
|
| -+#undef ZLIB_DLL
|
| ++#ifdef _MSC_VER
|
| ++#define INLINE __inline
|
| ++#else
|
| ++#define INLINE inline
|
| +#endif
|
| +
|
| -+#ifdef HAVE_VISIBILITY_ATTRIBUTE
|
| -+#define ZEXTERN __attribute__((visibility ("default"))) extern
|
| -+#endif
|
| ++/* Inline optimisation */
|
| ++local INLINE Pos insert_string_sse(deflate_state *const s, const Pos str);
|
| +
|
| -+/* Exported Symbols */
|
| -+#define zlibVersion MOZ_Z_zlibVersion
|
| -+#define deflate MOZ_Z_deflate
|
| -+#define deflateEnd MOZ_Z_deflateEnd
|
| -+#define inflate MOZ_Z_inflate
|
| -+#define inflateEnd MOZ_Z_inflateEnd
|
| -+#define deflateSetDictionary MOZ_Z_deflateSetDictionary
|
| -+#define deflateCopy MOZ_Z_deflateCopy
|
| -+#define deflateReset MOZ_Z_deflateReset
|
| -+#define deflateParams MOZ_Z_deflateParams
|
| -+#define deflateBound MOZ_Z_deflateBound
|
| -+#define deflatePrime MOZ_Z_deflatePrime
|
| -+#define inflateSetDictionary MOZ_Z_inflateSetDictionary
|
| -+#define inflateSync MOZ_Z_inflateSync
|
| -+#define inflateCopy MOZ_Z_inflateCopy
|
| -+#define inflateReset MOZ_Z_inflateReset
|
| -+#define inflateBack MOZ_Z_inflateBack
|
| -+#define inflateBackEnd MOZ_Z_inflateBackEnd
|
| -+#define zlibCompileFlags MOZ_Z_zlibCompileFlags
|
| -+#define compress MOZ_Z_compress
|
| -+#define compress2 MOZ_Z_compress2
|
| -+#define compressBound MOZ_Z_compressBound
|
| -+#define uncompress MOZ_Z_uncompress
|
| -+#define gzopen MOZ_Z_gzopen
|
| -+#define gzdopen MOZ_Z_gzdopen
|
| -+#define gzsetparams MOZ_Z_gzsetparams
|
| -+#define gzread MOZ_Z_gzread
|
| -+#define gzwrite MOZ_Z_gzwrite
|
| -+#define gzprintf MOZ_Z_gzprintf
|
| -+#define gzputs MOZ_Z_gzputs
|
| -+#define gzgets MOZ_Z_gzgets
|
| -+#define gzputc MOZ_Z_gzputc
|
| -+#define gzgetc MOZ_Z_gzgetc
|
| -+#define gzungetc MOZ_Z_gzungetc
|
| -+#define gzflush MOZ_Z_gzflush
|
| -+#define gzseek MOZ_Z_gzseek
|
| -+#define gzrewind MOZ_Z_gzrewind
|
| -+#define gztell MOZ_Z_gztell
|
| -+#define gzeof MOZ_Z_gzeof
|
| -+#define gzclose MOZ_Z_gzclose
|
| -+#define gzerror MOZ_Z_gzerror
|
| -+#define gzclearerr MOZ_Z_gzclearerr
|
| -+#define adler32 MOZ_Z_adler32
|
| -+#define crc32 MOZ_Z_crc32
|
| -+#define deflateInit_ MOZ_Z_deflateInit_
|
| -+#define deflateInit2_ MOZ_Z_deflateInit2_
|
| -+#define inflateInit_ MOZ_Z_inflateInit_
|
| -+#define inflateInit2_ MOZ_Z_inflateInit2_
|
| -+#define inflateBackInit_ MOZ_Z_inflateBackInit_
|
| -+#define inflateSyncPoint MOZ_Z_inflateSyncPoint
|
| -+#define get_crc_table MOZ_Z_get_crc_table
|
| -+#define zError MOZ_Z_zError
|
| -+
|
| -+/* Extra global symbols */
|
| -+#define _dist_code MOZ_Z__dist_code
|
| -+#define _length_code MOZ_Z__length_code
|
| -+#define _tr_align MOZ_Z__tr_align
|
| -+#define _tr_flush_block MOZ_Z__tr_flush_block
|
| -+#define _tr_init MOZ_Z__tr_init
|
| -+#define _tr_stored_block MOZ_Z__tr_stored_block
|
| -+#define _tr_tally MOZ_Z__tr_tally
|
| -+#define deflate_copyright MOZ_Z_deflate_copyright
|
| -+#define inflate_copyright MOZ_Z_inflate_copyright
|
| -+#define inflate_fast MOZ_Z_inflate_fast
|
| -+#define inflate_table MOZ_Z_inflate_table
|
| -+#define z_errmsg MOZ_Z_z_errmsg
|
| -+#define zcalloc MOZ_Z_zcalloc
|
| -+#define zcfree MOZ_Z_zcfree
|
| -+#define alloc_func MOZ_Z_alloc_func
|
| -+#define free_func MOZ_Z_free_func
|
| -+#define in_func MOZ_Z_in_func
|
| -+#define out_func MOZ_Z_out_func
|
| -+
|
| -+/* New as of libpng-1.2.3 */
|
| -+#define adler32_combine MOZ_Z_adler32_combine
|
| -+#define crc32_combine MOZ_Z_crc32_combine
|
| -+#define deflateSetHeader MOZ_Z_deflateSetHeader
|
| -+#define deflateTune MOZ_Z_deflateTune
|
| -+#define gzdirect MOZ_Z_gzdirect
|
| -+#define inflatePrime MOZ_Z_inflatePrime
|
| -+#define inflateGetHeader MOZ_Z_inflateGetHeader
|
| -+
|
| -+/* New as of zlib 1.2.5 */
|
| -+#define gzoffset MOZ_Z_gzoffset
|
| -+#define gzopen64 MOZ_Z_gzopen64
|
| -+#define gzseek64 MOZ_Z_gzseek64
|
| -+#define gztell64 MOZ_Z_gztell64
|
| -+#define gzoffset64 MOZ_Z_gzoffset64
|
| -+#define adler32_combine64 MOZ_Z_adler32_combine64
|
| -+#define crc32_combine64 MOZ_Z_crc32_combine64
|
| -+#define gz_error MOZ_Z_gz_error
|
| -+#define gz_intmax MOZ_Z_gz_intmax
|
| -+#define gz_strwinerror MOZ_Z_gz_strwinerror
|
| -+#define gzbuffer MOZ_Z_gzbuffer
|
| -+#define gzclose_r MOZ_Z_gzclose_r
|
| -+#define gzclose_w MOZ_Z_gzclose_w
|
| -+#define inflateMark MOZ_Z_inflateMark
|
| -+#define inflateReset2 MOZ_Z_inflateReset2
|
| -+#define inflateUndermine MOZ_Z_inflateUndermine
|
| -+#define charf MOZ_Z_charf
|
| -+#define gzFile MOZ_Z_gzFile
|
| -+#define gz_header MOZ_Z_gz_header
|
| -+#define gz_headerp MOZ_Z_gz_headerp
|
| -+#define intf MOZ_Z_intf
|
| -+#define uInt MOZ_Z_uInt
|
| -+#define uIntf MOZ_Z_uIntf
|
| -+#define uLong MOZ_Z_uLong
|
| -+#define uLongf MOZ_Z_uLongf
|
| -+#define voidp MOZ_Z_voidp
|
| -+#define voidpc MOZ_Z_voidpc
|
| -+#define voidpf MOZ_Z_voidpf
|
| -+#define gz_header_s MOZ_Z_gz_header_s
|
| -+#define internal_state MOZ_Z_internal_state
|
| -+
|
| -+/* Mangle Byte types except on Mac. */
|
| -+#if !defined(__MACTYPES__)
|
| -+#define Byte MOZ_Z_Byte
|
| -+#define Bytef MOZ_Z_Bytef
|
| -+#endif
|
| + /* ===========================================================================
|
| + * Local data
|
| + */
|
| +@@ -166,7 +187,6 @@
|
| + */
|
| + #define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
|
| +
|
| +-
|
| + /* ===========================================================================
|
| + * Insert string str in the dictionary and set match_head to the previous head
|
| + * of the hash chain (the most recent string with same hash key). Return
|
| +@@ -177,17 +197,28 @@
|
| + * input characters and the first MIN_MATCH bytes of str are valid
|
| + * (except for the last MIN_MATCH-1 bytes of the input file).
|
| + */
|
| ++local INLINE Pos insert_string_c(deflate_state *const s, const Pos str)
|
| ++{
|
| ++ Pos ret;
|
| +
|
| ++ UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]);
|
| + #ifdef FASTEST
|
| +-#define INSERT_STRING(s, str, match_head) \
|
| +- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
|
| +- match_head = s->head[s->ins_h], \
|
| +- s->head[s->ins_h] = (Pos)(str))
|
| ++ ret = s->head[s->ins_h];
|
| + #else
|
| +-#define INSERT_STRING(s, str, match_head) \
|
| +- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
|
| +- match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
|
| +- s->head[s->ins_h] = (Pos)(str))
|
| ++ ret = s->prev[str & s->w_mask] = s->head[s->ins_h];
|
| + #endif
|
| ++ s->head[s->ins_h] = str;
|
| ++
|
| ++ return ret;
|
| ++}
|
| ++
|
| ++local INLINE Pos insert_string(deflate_state *const s, const Pos str)
|
| ++{
|
| ++ if (x86_cpu_enable_simd)
|
| ++ return insert_string_sse(s, str);
|
| ++ return insert_string_c(s, str);
|
| ++}
|
| ++
|
| +
|
| + /* ===========================================================================
|
| + * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
|
| +@@ -221,6 +252,7 @@
|
| + const char *version;
|
| + int stream_size;
|
| + {
|
| ++ unsigned window_padding = 8;
|
| + deflate_state *s;
|
| + int wrap = 1;
|
| + static const char my_version[] = ZLIB_VERSION;
|
| +@@ -230,6 +262,8 @@
|
| + * output size for (length,distance) codes is <= 24 bits.
|
| + */
|
| +
|
| ++ x86_check_features();
|
| ++
|
| + if (version == Z_NULL || version[0] != my_version[0] ||
|
| + stream_size != sizeof(z_stream)) {
|
| + return Z_VERSION_ERROR;
|
| +@@ -285,14 +319,22 @@
|
| + s->w_size = 1 << s->w_bits;
|
| + s->w_mask = s->w_size - 1;
|
| +
|
| +- s->hash_bits = memLevel + 7;
|
| ++ if (x86_cpu_enable_simd) {
|
| ++ s->hash_bits = 15;
|
| ++ } else {
|
| ++ s->hash_bits = memLevel + 7;
|
| ++ }
|
| ++
|
| + s->hash_size = 1 << s->hash_bits;
|
| + s->hash_mask = s->hash_size - 1;
|
| + s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
|
| +
|
| +- s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
|
| ++ s->window = (Bytef *) ZALLOC(strm, s->w_size + window_padding, 2*sizeof(Byte));
|
| + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
|
| + s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
|
| ++ s->class_bitmap = NULL;
|
| ++ zmemzero(&s->cookie_locations, sizeof(s->cookie_locations));
|
| ++ strm->clas = 0;
|
| +
|
| + s->high_water = 0; /* nothing written to s->window yet */
|
| +
|
| +@@ -406,6 +448,8 @@
|
| + s = (deflate_state *)strm->state;
|
| + s->pending = 0;
|
| + s->pending_out = s->pending_buf;
|
| ++ TRY_FREE(strm, s->class_bitmap);
|
| ++ s->class_bitmap = NULL;
|
| +
|
| + if (s->wrap < 0) {
|
| + s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
|
| +@@ -690,7 +734,7 @@
|
| + if (s->status == INIT_STATE) {
|
| + #ifdef GZIP
|
| + if (s->wrap == 2) {
|
| +- strm->adler = crc32(0L, Z_NULL, 0);
|
| ++ crc_reset(s);
|
| + put_byte(s, 31);
|
| + put_byte(s, 139);
|
| + put_byte(s, 8);
|
| +@@ -900,9 +944,26 @@
|
| + (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
|
| + block_state bstate;
|
| +
|
| +- bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
|
| +- (s->strategy == Z_RLE ? deflate_rle(s, flush) :
|
| +- (*(configuration_table[s->level].func))(s, flush));
|
| ++ if (strm->clas && s->class_bitmap == NULL) {
|
| ++ /* This is the first time that we have seen alternative class
|
| ++ * data. All data up till this point has been standard class. */
|
| ++ s->class_bitmap = (Bytef*) ZALLOC(strm, s->w_size/4, sizeof(Byte));
|
| ++ zmemzero(s->class_bitmap, s->w_size/4);
|
| ++ }
|
| ++
|
| ++ if (strm->clas && s->strategy == Z_RLE) {
|
| ++ /* We haven't patched deflate_rle. */
|
| ++ ERR_RETURN(strm, Z_BUF_ERROR);
|
| ++ }
|
| ++
|
| ++ if (s->strategy == Z_HUFFMAN_ONLY) {
|
| ++ bstate = deflate_huff(s, flush);
|
| ++ } else if (s->strategy == Z_RLE) {
|
| ++ bstate = deflate_rle(s, flush);
|
| ++ } else {
|
| ++ bstate = (*(configuration_table[s->level].func))
|
| ++ (s, flush, strm->clas);
|
| ++ }
|
| +
|
| + if (bstate == finish_started || bstate == finish_done) {
|
| + s->status = FINISH_STATE;
|
| +@@ -952,6 +1013,7 @@
|
| + /* Write the trailer */
|
| + #ifdef GZIP
|
| + if (s->wrap == 2) {
|
| ++ crc_finalize(s);
|
| + put_byte(s, (Byte)(strm->adler & 0xff));
|
| + put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
|
| + put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
|
| +@@ -999,6 +1061,7 @@
|
| + TRY_FREE(strm, strm->state->head);
|
| + TRY_FREE(strm, strm->state->prev);
|
| + TRY_FREE(strm, strm->state->window);
|
| ++ TRY_FREE(strm, strm->state->class_bitmap);
|
| +
|
| + ZFREE(strm, strm->state);
|
| + strm->state = Z_NULL;
|
| +@@ -1073,7 +1136,7 @@
|
| + * allocating a large strm->next_in buffer and copying from it.
|
| + * (See also flush_pending()).
|
| + */
|
| +-local int read_buf(strm, buf, size)
|
| ++ZLIB_INTERNAL int read_buf(strm, buf, size)
|
| + z_streamp strm;
|
| + Bytef *buf;
|
| + unsigned size;
|
| +@@ -1085,15 +1148,17 @@
|
| +
|
| + strm->avail_in -= len;
|
| +
|
| +- zmemcpy(buf, strm->next_in, len);
|
| +- if (strm->state->wrap == 1) {
|
| +- strm->adler = adler32(strm->adler, buf, len);
|
| +- }
|
| + #ifdef GZIP
|
| +- else if (strm->state->wrap == 2) {
|
| +- strm->adler = crc32(strm->adler, buf, len);
|
| ++ if (strm->state->wrap == 2) {
|
| ++ copy_with_crc(strm, buf, len);
|
| + }
|
| ++ else
|
| + #endif
|
| ++ {
|
| ++ zmemcpy(buf, strm->next_in, len);
|
| ++ if (strm->state->wrap == 1)
|
| ++ strm->adler = adler32(strm->adler, buf, len);
|
| ++ }
|
| + strm->next_in += len;
|
| + strm->total_in += len;
|
| +
|
| +@@ -1131,6 +1196,57 @@
|
| + #endif
|
| + }
|
| +
|
| ++/* class_set sets bits [offset,offset+len) in s->class_bitmap to either 1 (if
|
| ++ * class != 0) or 0 (otherwise). */
|
| ++local void class_set(s, offset, len, clas)
|
| ++ deflate_state *s;
|
| ++ IPos offset;
|
| ++ uInt len;
|
| ++ int clas;
|
| ++{
|
| ++ IPos byte = offset >> 3;
|
| ++ IPos bit = offset & 7;
|
| ++ Bytef class_byte_value = clas ? 0xff : 0x00;
|
| ++ Bytef class_bit_value = clas ? 1 : 0;
|
| ++ static const Bytef mask[8] = {0xfe, 0xfd, 0xfb, 0xf7,
|
| ++ 0xef, 0xdf, 0xbf, 0x7f};
|
| ++
|
| ++ if (bit) {
|
| ++ while (len) {
|
| ++ s->class_bitmap[byte] &= mask[bit];
|
| ++ s->class_bitmap[byte] |= class_bit_value << bit;
|
| ++ bit++;
|
| ++ len--;
|
| ++ if (bit == 8) {
|
| ++ bit = 0;
|
| ++ byte++;
|
| ++ break;
|
| ++ }
|
| ++ }
|
| ++ }
|
| ++
|
| ++ while (len >= 8) {
|
| ++ s->class_bitmap[byte++] = class_byte_value;
|
| ++ len -= 8;
|
| ++ }
|
| ++
|
| ++ while (len) {
|
| ++ s->class_bitmap[byte] &= mask[bit];
|
| ++ s->class_bitmap[byte] |= class_bit_value << bit;
|
| ++ bit++;
|
| ++ len--;
|
| ++ }
|
| ++}
|
| ++
|
| ++local int class_at(s, window_offset)
|
| ++ deflate_state *s;
|
| ++ IPos window_offset;
|
| ++{
|
| ++ IPos byte = window_offset >> 3;
|
| ++ IPos bit = window_offset & 7;
|
| ++ return (s->class_bitmap[byte] >> bit) & 1;
|
| ++}
|
| ++
|
| + #ifndef FASTEST
|
| + /* ===========================================================================
|
| + * Set match_start to the longest match starting at the given string and
|
| +@@ -1145,9 +1261,10 @@
|
| + /* For 80x86 and 680x0, an optimized version will be provided in match.asm or
|
| + * match.S. The code will be functionally equivalent.
|
| + */
|
| +-local uInt longest_match(s, cur_match)
|
| ++local uInt longest_match(s, cur_match, clas)
|
| + deflate_state *s;
|
| + IPos cur_match; /* current match */
|
| ++ int clas;
|
| + {
|
| + unsigned chain_length = s->max_chain_length;/* max hash chain length */
|
| + register Bytef *scan = s->window + s->strstart; /* current string */
|
| +@@ -1195,6 +1312,9 @@
|
| + do {
|
| + Assert(cur_match < s->strstart, "no future");
|
| + match = s->window + cur_match;
|
| ++ /* If the matched data is in the wrong class, skip it. */
|
| ++ if (s->class_bitmap && class_at(s, cur_match) != clas)
|
| ++ continue;
|
| +
|
| + /* Skip to next match if the match length cannot increase
|
| + * or if the match length is less than 2. Note that the checks below
|
| +@@ -1237,6 +1357,8 @@
|
| + len = (MAX_MATCH - 1) - (int)(strend-scan);
|
| + scan = strend - (MAX_MATCH-1);
|
| +
|
| ++#error "UNALIGNED_OK hasn't been patched."
|
| ++
|
| + #else /* UNALIGNED_OK */
|
| +
|
| + if (match[best_len] != scan_end ||
|
| +@@ -1253,15 +1375,23 @@
|
| + scan += 2, match++;
|
| + Assert(*scan == *match, "match[2]?");
|
| +
|
| +- /* We check for insufficient lookahead only every 8th comparison;
|
| +- * the 256th check will be made at strstart+258.
|
| +- */
|
| +- do {
|
| +- } while (*++scan == *++match && *++scan == *++match &&
|
| +- *++scan == *++match && *++scan == *++match &&
|
| +- *++scan == *++match && *++scan == *++match &&
|
| +- *++scan == *++match && *++scan == *++match &&
|
| +- scan < strend);
|
| ++ if (!s->class_bitmap) {
|
| ++ /* We check for insufficient lookahead only every 8th comparison;
|
| ++ * the 256th check will be made at strstart+258.
|
| ++ */
|
| ++ do {
|
| ++ } while (*++scan == *++match && *++scan == *++match &&
|
| ++ *++scan == *++match && *++scan == *++match &&
|
| ++ *++scan == *++match && *++scan == *++match &&
|
| ++ *++scan == *++match && *++scan == *++match &&
|
| ++ scan < strend);
|
| ++ } else {
|
| ++ /* We have to be mindful of the class of the data and not stray. */
|
| ++ do {
|
| ++ } while (*++scan == *++match &&
|
| ++ class_at(s, match - s->window) == clas &&
|
| ++ scan < strend);
|
| ++ }
|
| +
|
| + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
|
| +
|
| +@@ -1289,20 +1419,74 @@
|
| + }
|
| + #endif /* ASMV */
|
| +
|
| ++/* cookie_match is a replacement for longest_match in the case of cookie data.
|
| ++ * Here we only wish to match the entire value so trying the partial matches in
|
| ++ * longest_match is both wasteful and often fails to find the correct match.
|
| ++ *
|
| ++ * So we take the djb2 hash of the cookie and look up the last position for a
|
| ++ * match in a special hash table. */
|
| ++local uInt cookie_match(s, start, len)
|
| ++ deflate_state *s;
|
| ++ IPos start;
|
| ++ unsigned len;
|
| ++{
|
| ++ unsigned hash = 5381;
|
| ++ Bytef *str = s->window + start;
|
| ++ unsigned i;
|
| ++ IPos cookie_location;
|
| ++
|
| ++ if (len >= MAX_MATCH || len == 0)
|
| ++ return 0;
|
| ++
|
| ++ for (i = 0; i < len; i++)
|
| ++ hash = ((hash << 5) + hash) + str[i];
|
| ++
|
| ++ hash &= Z_COOKIE_HASH_MASK;
|
| ++ cookie_location = s->cookie_locations[hash];
|
| ++ s->cookie_locations[hash] = start;
|
| ++ s->match_start = 0;
|
| ++ if (cookie_location &&
|
| ++ (start - cookie_location) > len &&
|
| ++ (start - cookie_location) < MAX_DIST(s) &&
|
| ++ len <= s->lookahead) {
|
| ++ for (i = 0; i < len; i++) {
|
| ++ if (s->window[start+i] != s->window[cookie_location+i] ||
|
| ++ class_at(s, cookie_location+i) != 1) {
|
| ++ return 0;
|
| ++ }
|
| ++ }
|
| ++ /* Check that we aren't matching a prefix of another cookie by ensuring
|
| ++ * that the final byte is either a semicolon (which cannot appear in a
|
| ++ * cookie value), or the match is followed by non-cookie data. */
|
| ++ if (s->window[cookie_location+len-1] != ';' &&
|
| ++ class_at(s, cookie_location+len) != 0) {
|
| ++ return 0;
|
| ++ }
|
| ++ s->match_start = cookie_location;
|
| ++ return len;
|
| ++ }
|
| ++
|
| ++ return 0;
|
| ++}
|
| ++
|
| ++
|
| + #else /* FASTEST */
|
| +
|
| + /* ---------------------------------------------------------------------------
|
| + * Optimized version for FASTEST only
|
| + */
|
| +-local uInt longest_match(s, cur_match)
|
| ++local uInt longest_match(s, cur_match, clas)
|
| + deflate_state *s;
|
| + IPos cur_match; /* current match */
|
| ++ int clas;
|
| + {
|
| + register Bytef *scan = s->window + s->strstart; /* current string */
|
| + register Bytef *match; /* matched string */
|
| + register int len; /* length of current match */
|
| + register Bytef *strend = s->window + s->strstart + MAX_MATCH;
|
| +
|
| ++#error "This code not patched"
|
| ++
|
| + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
|
| + * It is easy to get rid of this optimization if necessary.
|
| + */
|
| +@@ -1387,7 +1571,19 @@
|
| + * performed for at least two bytes (required for the zip translate_eol
|
| + * option -- not supported here).
|
| + */
|
| +-local void fill_window(s)
|
| ++local void fill_window_c(deflate_state *s);
|
| ++
|
| ++local void fill_window(deflate_state *s)
|
| ++{
|
| ++ if (x86_cpu_enable_simd) {
|
| ++ fill_window_sse(s);
|
| ++ return;
|
| ++ }
|
| ++
|
| ++ fill_window_c(s);
|
| ++}
|
| ++
|
| ++local void fill_window_c(s)
|
| + deflate_state *s;
|
| + {
|
| + register unsigned n, m;
|
| +@@ -1447,6 +1643,21 @@
|
| + */
|
| + } while (--n);
|
| + #endif
|
| ++
|
| ++ for (n = 0; n < Z_COOKIE_HASH_SIZE; n++) {
|
| ++ if (s->cookie_locations[n] > wsize) {
|
| ++ s->cookie_locations[n] -= wsize;
|
| ++ } else {
|
| ++ s->cookie_locations[n] = 0;
|
| ++ }
|
| ++ }
|
| ++
|
| ++ if (s->class_bitmap) {
|
| ++ zmemcpy(s->class_bitmap, s->class_bitmap + s->w_size/8,
|
| ++ s->w_size/8);
|
| ++ zmemzero(s->class_bitmap + s->w_size/8, s->w_size/8);
|
| ++ }
|
| ++
|
| + more += wsize;
|
| + }
|
| + if (s->strm->avail_in == 0) break;
|
| +@@ -1465,6 +1676,9 @@
|
| + Assert(more >= 2, "more < 2");
|
| +
|
| + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
|
| ++ if (s->class_bitmap != NULL) {
|
| ++ class_set(s, s->strstart + s->lookahead, n, s->strm->clas);
|
| ++ }
|
| + s->lookahead += n;
|
| +
|
| + /* Initialize the hash value now that we have some input: */
|
| +@@ -1561,9 +1775,10 @@
|
| + * NOTE: this function should be optimized to avoid extra copying from
|
| + * window to pending_buf.
|
| + */
|
| +-local block_state deflate_stored(s, flush)
|
| ++local block_state deflate_stored(s, flush, clas)
|
| + deflate_state *s;
|
| + int flush;
|
| ++ int clas;
|
| + {
|
| + /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
|
| + * to pending_buf_size, and each stored block has a 5 byte header:
|
| +@@ -1625,13 +1840,19 @@
|
| + * new strings in the dictionary only for unmatched strings or for short
|
| + * matches. It is used only for the fast compression options.
|
| + */
|
| +-local block_state deflate_fast(s, flush)
|
| ++local block_state deflate_fast(s, flush, clas)
|
| + deflate_state *s;
|
| + int flush;
|
| ++ int clas;
|
| + {
|
| + IPos hash_head; /* head of the hash chain */
|
| + int bflush; /* set if current block must be flushed */
|
| +
|
| ++ if (clas != 0) {
|
| ++ /* We haven't patched this code for alternative class data. */
|
| ++ return Z_BUF_ERROR;
|
| ++ }
|
| ++
|
| + for (;;) {
|
| + /* Make sure that we always have enough lookahead, except
|
| + * at the end of the input file. We need MAX_MATCH bytes
|
| +@@ -1651,7 +1872,7 @@
|
| + */
|
| + hash_head = NIL;
|
| + if (s->lookahead >= MIN_MATCH) {
|
| +- INSERT_STRING(s, s->strstart, hash_head);
|
| ++ hash_head = insert_string(s, s->strstart);
|
| + }
|
| +
|
| + /* Find the longest match, discarding those <= prev_length.
|
| +@@ -1662,7 +1883,7 @@
|
| + * of window index 0 (in particular we have to avoid a match
|
| + * of the string with itself at the start of the input file).
|
| + */
|
| +- s->match_length = longest_match (s, hash_head);
|
| ++ s->match_length = longest_match (s, hash_head, clas);
|
| + /* longest_match() sets match_start */
|
| + }
|
| + if (s->match_length >= MIN_MATCH) {
|
| +@@ -1682,7 +1903,7 @@
|
| + s->match_length--; /* string at strstart already in table */
|
| + do {
|
| + s->strstart++;
|
| +- INSERT_STRING(s, s->strstart, hash_head);
|
| ++ hash_head = insert_string(s, s->strstart);
|
| + /* strstart never exceeds WSIZE-MAX_MATCH, so there are
|
| + * always MIN_MATCH bytes ahead.
|
| + */
|
| +@@ -1727,12 +1948,25 @@
|
| + * evaluation for matches: a match is finally adopted only if there is
|
| + * no better match at the next window position.
|
| + */
|
| +-local block_state deflate_slow(s, flush)
|
| ++local block_state deflate_slow(s, flush, clas)
|
| + deflate_state *s;
|
| + int flush;
|
| ++ int clas;
|
| + {
|
| + IPos hash_head; /* head of hash chain */
|
| + int bflush; /* set if current block must be flushed */
|
| ++ uInt input_length ;
|
| ++ int first = 1; /* first says whether this is the first iteration
|
| ++ of the loop, below. */
|
| ++
|
| ++ if (clas == Z_CLASS_COOKIE) {
|
| ++ if (s->lookahead) {
|
| ++ /* Alternative class data must always be presented at the beginning
|
| ++ * of a block. */
|
| ++ return Z_BUF_ERROR;
|
| ++ }
|
| ++ input_length = s->strm->avail_in;
|
| ++ }
|
| +
|
| + /* Process the input block. */
|
| + for (;;) {
|
| +@@ -1754,7 +1988,7 @@
|
| + */
|
| + hash_head = NIL;
|
| + if (s->lookahead >= MIN_MATCH) {
|
| +- INSERT_STRING(s, s->strstart, hash_head);
|
| ++ hash_head = insert_string(s, s->strstart);
|
| + }
|
| +
|
| + /* Find the longest match, discarding those <= prev_length.
|
| +@@ -1762,13 +1996,18 @@
|
| + s->prev_length = s->match_length, s->prev_match = s->match_start;
|
| + s->match_length = MIN_MATCH-1;
|
| +
|
| +- if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
|
| +- s->strstart - hash_head <= MAX_DIST(s)) {
|
| ++ if (clas == Z_CLASS_COOKIE && first) {
|
| ++ s->match_length = cookie_match(s, s->strstart, input_length);
|
| ++ } else if (clas == Z_CLASS_STANDARD &&
|
| ++ hash_head != NIL &&
|
| ++ s->prev_length < s->max_lazy_match &&
|
| ++ s->strstart - hash_head <= MAX_DIST(s)) {
|
| + /* To simplify the code, we prevent matches with the string
|
| + * of window index 0 (in particular we have to avoid a match
|
| + * of the string with itself at the start of the input file).
|
| + */
|
| +- s->match_length = longest_match (s, hash_head);
|
| ++ s->match_length = longest_match (s, hash_head, clas);
|
| ++
|
| + /* longest_match() sets match_start */
|
| +
|
| + if (s->match_length <= 5 && (s->strategy == Z_FILTERED
|
| +@@ -1787,7 +2026,20 @@
|
| + /* If there was a match at the previous step and the current
|
| + * match is not better, output the previous match:
|
| + */
|
| +- if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
|
| ++ first = 0;
|
| ++ if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length &&
|
| ++ /* We will only accept an exact match for Z_CLASS_COOKIE data and
|
| ++ * we won't match Z_CLASS_HUFFMAN_ONLY data at all. */
|
| ++ (clas == Z_CLASS_STANDARD || (clas == Z_CLASS_COOKIE &&
|
| ++ s->prev_length == input_length &&
|
| ++ s->prev_match > 0 &&
|
| ++ /* We require that a Z_CLASS_COOKIE match be
|
| ++ * preceded by either a semicolon (which cannot be
|
| ++ * part of a cookie), or non-cookie data. This is
|
| ++ * to prevent a cookie from being a suffix of
|
| ++ * another. */
|
| ++ (class_at(s, s->prev_match-1) == Z_CLASS_STANDARD ||
|
| ++ *(s->window + s->prev_match-1) == ';')))) {
|
| + uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
|
| + /* Do not insert strings in hash table beyond this. */
|
| +
|
| +@@ -1805,7 +2057,7 @@
|
| + s->prev_length -= 2;
|
| + do {
|
| + if (++s->strstart <= max_insert) {
|
| +- INSERT_STRING(s, s->strstart, hash_head);
|
| ++ hash_head = insert_string(s, s->strstart);
|
| + }
|
| + } while (--s->prev_length != 0);
|
| + s->match_available = 0;
|
| +@@ -1965,3 +2217,37 @@
|
| + FLUSH_BLOCK(s, 0);
|
| + return block_done;
|
| + }
|
| ++
|
| ++/* Safe to inline this as GCC/clang will use inline asm and Visual Studio will
|
| ++ * use intrinsic without extra params
|
| ++ */
|
| ++local INLINE Pos insert_string_sse(deflate_state *const s, const Pos str)
|
| ++{
|
| ++ Pos ret;
|
| ++ unsigned *ip, val, h = 0;
|
| ++
|
| ++ ip = (unsigned *)&s->window[str];
|
| ++ val = *ip;
|
| ++
|
| ++ if (s->level >= 6)
|
| ++ val &= 0xFFFFFF;
|
| ++
|
| ++/* Windows clang should use inline asm */
|
| ++#if defined(_MSC_VER) && !defined(__clang__)
|
| ++ h = _mm_crc32_u32(h, val);
|
| ++#elif defined(__i386__) || defined(__amd64__)
|
| ++ __asm__ __volatile__ (
|
| ++ "crc32 %1,%0\n\t"
|
| ++ : "+r" (h)
|
| ++ : "r" (val)
|
| ++ );
|
| ++#else
|
| ++ /* This should never happen */
|
| ++ assert(0);
|
| +#endif
|
| -diff -ru zlib-1.2.5/zconf.h zlib/zconf.h
|
| ---- zlib-1.2.5/zconf.h 2010-04-19 01:58:06.000000000 +0800
|
| -+++ zlib/zconf.h 2011-12-14 08:06:37.000000000 +0800
|
| ++
|
| ++ ret = s->head[h & s->hash_mask];
|
| ++ s->head[h & s->hash_mask] = str;
|
| ++ s->prev[str & s->w_mask] = ret;
|
| ++ return ret;
|
| ++}
|
| +diff -ru zlib-1.2.8/deflate.h zlib/deflate.h
|
| +--- zlib-1.2.8/deflate.h 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/deflate.h 2016-05-13 17:32:21.454780493 +0800
|
| +@@ -94,6 +94,9 @@
|
| + * save space in the various tables. IPos is used only for parameter passing.
|
| + */
|
| +
|
| ++#define Z_COOKIE_HASH_SIZE 256
|
| ++#define Z_COOKIE_HASH_MASK (Z_COOKIE_HASH_SIZE-1)
|
| ++
|
| + typedef struct internal_state {
|
| + z_streamp strm; /* pointer back to this zlib stream */
|
| + int status; /* as the name implies */
|
| +@@ -107,6 +110,8 @@
|
| + Byte method; /* can only be DEFLATED */
|
| + int last_flush; /* value of flush param for previous deflate call */
|
| +
|
| ++ unsigned zalign(16) crc0[4 * 5];
|
| ++
|
| + /* used by deflate.c: */
|
| +
|
| + uInt w_size; /* LZ77 window size (32K by default) */
|
| +@@ -142,6 +147,8 @@
|
| + uInt hash_mask; /* hash_size-1 */
|
| +
|
| + uInt hash_shift;
|
| ++ Bytef *class_bitmap; /* bitmap of class for each byte in window */
|
| ++ IPos cookie_locations[Z_COOKIE_HASH_SIZE];
|
| + /* Number of bits by which ins_h must be shifted at each input
|
| + * step. It must be such that after MIN_MATCH steps, the oldest
|
| + * byte no longer takes part in the hash key, that is:
|
| +@@ -343,4 +350,14 @@
|
| + flush = _tr_tally(s, distance, length)
|
| + #endif
|
| +
|
| ++/* Functions that are SIMD optimised on x86 */
|
| ++void ZLIB_INTERNAL crc_fold_init(deflate_state* const s);
|
| ++void ZLIB_INTERNAL crc_fold_copy(deflate_state* const s,
|
| ++ unsigned char* dst,
|
| ++ const unsigned char* src,
|
| ++ long len);
|
| ++unsigned ZLIB_INTERNAL crc_fold_512to32(deflate_state* const s);
|
| ++
|
| ++void ZLIB_INTERNAL fill_window_sse(deflate_state* s);
|
| ++
|
| + #endif /* DEFLATE_H */
|
| +diff -ru zlib-1.2.8/gzlib.c zlib/gzlib.c
|
| +--- zlib-1.2.8/gzlib.c 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/gzlib.c 2016-05-13 17:32:21.454780493 +0800
|
| +@@ -6,14 +6,12 @@
|
| + #include "gzguts.h"
|
| +
|
| + #if defined(_WIN32) && !defined(__BORLANDC__)
|
| +-# define LSEEK _lseeki64
|
| +-#else
|
| +-#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
| ++# define LSEEK (z_off64_t)_lseeki64
|
| ++#elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
| + # define LSEEK lseek64
|
| + #else
|
| + # define LSEEK lseek
|
| + #endif
|
| +-#endif
|
| +
|
| + /* Local functions */
|
| + local void gz_reset OF((gz_statep));
|
| +diff -ru zlib-1.2.8/zconf.h zlib/zconf.h
|
| +--- zlib-1.2.8/zconf.h 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/zconf.h 2016-05-13 17:32:21.454780493 +0800
|
| @@ -8,6 +8,9 @@
|
| #ifndef ZCONF_H
|
| #define ZCONF_H
|
| @@ -197,8 +909,8 @@ diff -ru zlib-1.2.5/zconf.h zlib/zconf.h
|
| /*
|
| * If you *really* need a unique prefix for all types and library functions,
|
| * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
| -@@ -359,7 +359,7 @@ typedef uLong FAR uLongf;
|
| - typedef Byte *voidp;
|
| +@@ -408,7 +411,7 @@
|
| + typedef unsigned long z_crc_t;
|
| #endif
|
|
|
| -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
| @@ -206,35 +918,123 @@ diff -ru zlib-1.2.5/zconf.h zlib/zconf.h
|
| # define Z_HAVE_UNISTD_H
|
| #endif
|
|
|
| ---- zlib-1.2.5/zlib.h 2010-04-20 12:12:48.000000000 +0800
|
| -+++ zlib/zlib.h 2013-04-06 16:08:48.000000000 +0800
|
| -@@ -1572,11 +1572,29 @@
|
| - #endif
|
| +diff -ru zlib-1.2.8/zlib.h zlib/zlib.h
|
| +--- zlib-1.2.8/zlib.h 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/zlib.h 2016-05-13 18:32:20.751343000 +0800
|
| +@@ -101,6 +101,7 @@
|
| + int data_type; /* best guess about the data type: binary or text */
|
| + uLong adler; /* adler32 value of the uncompressed data */
|
| + uLong reserved; /* reserved for future use */
|
| ++ int clas;
|
| + } z_stream;
|
|
|
| - #if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
|
| -+# ifdef gzopen
|
| -+# undef gzopen
|
| -+# endif
|
| - # define gzopen gzopen64
|
| -+# ifdef gzseek
|
| -+# undef gzseek
|
| -+# endif
|
| - # define gzseek gzseek64
|
| -+# ifdef gztell
|
| -+# undef gztell
|
| -+# endif
|
| - # define gztell gztell64
|
| -+# ifdef gzoffset
|
| -+# undef gzoffset
|
| -+# endif
|
| - # define gzoffset gzoffset64
|
| -+# ifdef adler32_combine
|
| -+# undef adler32_combine
|
| + typedef z_stream FAR *z_streamp;
|
| +@@ -207,6 +208,10 @@
|
| +
|
| + #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
|
| +
|
| ++#define Z_CLASS_STANDARD 0
|
| ++#define Z_CLASS_COOKIE 1
|
| ++#define Z_CLASS_HUFFMAN_ONLY 2
|
| ++
|
| + #define zlib_version zlibVersion()
|
| + /* for compatibility with versions < 1.0.2 */
|
| +
|
| +@@ -1678,8 +1683,14 @@
|
| + # define z_gzgetc(g) \
|
| + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
|
| + #else
|
| +-# define gzgetc(g) \
|
| ++# ifdef MOZZCONF_H
|
| ++# undef gzgetc
|
| ++# define gzgetc(g) \
|
| ++ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : MOZ_Z_gzgetc(g))
|
| ++# else
|
| ++# define gzgetc(g) \
|
| + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
|
| +# endif
|
| - # define adler32_combine adler32_combine64
|
| -+# ifdef crc32_combine
|
| -+# undef crc32_combine
|
| + #endif
|
| +
|
| + /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
|
| +@@ -1706,11 +1717,29 @@
|
| + # define z_adler32_combine z_adler32_combine64
|
| + # define z_crc32_combine z_crc32_combine64
|
| + # else
|
| ++# ifdef gzopen
|
| ++# undef gzopen
|
| ++# endif
|
| + # define gzopen gzopen64
|
| ++# ifdef gzseek
|
| ++# undef gzseek
|
| ++# endif
|
| + # define gzseek gzseek64
|
| ++# ifdef gztell
|
| ++# undef gztell
|
| ++# endif
|
| + # define gztell gztell64
|
| ++# ifdef gzoffset
|
| ++# undef gzoffset
|
| ++# endif
|
| + # define gzoffset gzoffset64
|
| ++# ifdef adler32_combine
|
| ++# undef adler32_combine
|
| ++# endif
|
| + # define adler32_combine adler32_combine64
|
| ++# ifdef crc32_combine
|
| ++# undef crc32_combine
|
| ++# endif
|
| + # define crc32_combine crc32_combine64
|
| + # endif
|
| + # ifndef Z_LARGE64
|
| +@@ -1720,6 +1749,13 @@
|
| + ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
|
| + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
| + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
| ++# else
|
| ++ ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
|
| ++ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
|
| ++ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
|
| ++ ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
|
| ++ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
| ++ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
| + # endif
|
| + #else
|
| + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
|
| +diff -ru zlib-1.2.8/zutil.h zlib/zutil.h
|
| +--- zlib-1.2.8/zutil.h 2016-05-13 17:45:53.888988736 +0800
|
| ++++ zlib/zutil.h 2016-05-13 17:32:21.454780493 +0800
|
| +@@ -28,6 +28,21 @@
|
| + # include <string.h>
|
| + # include <stdlib.h>
|
| + #endif
|
| ++#ifdef NO_ERRNO_H
|
| ++# ifdef _WIN32_WCE
|
| ++ /* The Microsoft C Run-Time Library for Windows CE doesn't have
|
| ++ * errno. We define it as a global variable to simplify porting.
|
| ++ * Its value is always 0 and should not be used. We rename it to
|
| ++ * avoid conflict with other libraries that use the same workaround.
|
| ++ */
|
| ++# define errno z_errno
|
| ++# endif
|
| ++ extern int errno;
|
| ++#else
|
| ++# ifndef _WIN32_WCE
|
| ++# include <errno.h>
|
| +# endif
|
| - # define crc32_combine crc32_combine64
|
| - # ifdef _LARGEFILE64_SOURCE
|
| - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
| ++#endif
|
| +
|
| + #ifdef Z_SOLO
|
| + typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
|
| +@@ -135,6 +150,12 @@
|
| + # define OS_CODE 0x0a
|
| + #endif
|
| +
|
| ++#ifdef _MSC_VER
|
| ++#define zalign(x) __declspec(align(x))
|
| ++#else
|
| ++#define zalign(x) __attribute__((aligned((x))))
|
| ++#endif
|
| ++
|
| + #ifdef WIN32
|
| + # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
|
| + # define OS_CODE 0x0b
|
|
|