OLD | NEW |
1 diff -ru zlib-1.2.5/gzlib.c zlib/gzlib.c | 1 diff -ru zlib-1.2.8/contrib/minizip/ioapi.h zlib/contrib/minizip/ioapi.h |
2 --- zlib-1.2.5/gzlib.c | 2 --- zlib-1.2.8/contrib/minizip/ioapi.h 2016-05-13 17:45:53.888988736 +0800 |
3 +++ zlib/gzlib.c | 3 +++ zlib/contrib/minizip/ioapi.h 2016-05-13 17:32:21.510780073 +0800 |
4 @@ -5,7 +5,9 @@ | 4 @@ -43,7 +43,7 @@ |
5 | 5 |
| 6 #include <stdio.h> |
| 7 #include <stdlib.h> |
| 8 -#include "zlib.h" |
| 9 +#include "third_party/zlib/zlib.h" |
| 10 |
| 11 #if defined(USE_FILE32API) |
| 12 #define fopen64 fopen |
| 13 diff -ru zlib-1.2.8/contrib/minizip/mztools.c zlib/contrib/minizip/mztools.c |
| 14 --- zlib-1.2.8/contrib/minizip/mztools.c 2016-05-13 17:45:53.888988736 +0
800 |
| 15 +++ zlib/contrib/minizip/mztools.c 2016-05-13 17:32:21.510780073 +0800 |
| 16 @@ -8,7 +8,7 @@ |
| 17 #include <stdio.h> |
| 18 #include <stdlib.h> |
| 19 #include <string.h> |
| 20 -#include "zlib.h" |
| 21 +#include "third_party/zlib/zlib.h" |
| 22 #include "unzip.h" |
| 23 |
| 24 #define READ_8(adr) ((unsigned char)*(adr)) |
| 25 diff -ru zlib-1.2.8/contrib/minizip/mztools.h zlib/contrib/minizip/mztools.h |
| 26 --- zlib-1.2.8/contrib/minizip/mztools.h 2016-05-13 17:45:53.888988736 +0
800 |
| 27 +++ zlib/contrib/minizip/mztools.h 2016-05-13 17:32:21.510780073 +0800 |
| 28 @@ -12,7 +12,7 @@ |
| 29 #endif |
| 30 |
| 31 #ifndef _ZLIB_H |
| 32 -#include "zlib.h" |
| 33 +#include "third_party/zlib/zlib.h" |
| 34 #endif |
| 35 |
| 36 #include "unzip.h" |
| 37 diff -ru zlib-1.2.8/contrib/minizip/unzip.c zlib/contrib/minizip/unzip.c |
| 38 --- zlib-1.2.8/contrib/minizip/unzip.c 2016-05-13 17:45:53.888988736 +0800 |
| 39 +++ zlib/contrib/minizip/unzip.c 2016-05-13 17:32:21.510780073 +0800 |
| 40 @@ -72,7 +72,7 @@ |
| 41 #define NOUNCRYPT |
| 42 #endif |
| 43 |
| 44 -#include "zlib.h" |
| 45 +#include "third_party/zlib/zlib.h" |
| 46 #include "unzip.h" |
| 47 |
| 48 #ifdef STDC |
| 49 @@ -1705,11 +1705,6 @@ |
| 50 |
| 51 pfile_in_zip_read_info->stream.avail_out = (uInt)len; |
| 52 |
| 53 - if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && |
| 54 - (!(pfile_in_zip_read_info->raw))) |
| 55 - pfile_in_zip_read_info->stream.avail_out = |
| 56 - (uInt)pfile_in_zip_read_info->rest_read_uncompressed; |
| 57 - |
| 58 if ((len>pfile_in_zip_read_info->rest_read_compressed+ |
| 59 pfile_in_zip_read_info->stream.avail_in) && |
| 60 (pfile_in_zip_read_info->raw)) |
| 61 diff -ru zlib-1.2.8/contrib/minizip/unzip.h zlib/contrib/minizip/unzip.h |
| 62 --- zlib-1.2.8/contrib/minizip/unzip.h 2016-05-13 17:45:53.888988736 +0800 |
| 63 +++ zlib/contrib/minizip/unzip.h 2016-05-13 17:32:21.510780073 +0800 |
| 64 @@ -48,7 +48,7 @@ |
| 65 #endif |
| 66 |
| 67 #ifndef _ZLIB_H |
| 68 -#include "zlib.h" |
| 69 +#include "third_party/zlib/zlib.h" |
| 70 #endif |
| 71 |
| 72 #ifndef _ZLIBIOAPI_H |
| 73 diff -ru zlib-1.2.8/contrib/minizip/zip.c zlib/contrib/minizip/zip.c |
| 74 --- zlib-1.2.8/contrib/minizip/zip.c 2016-05-13 17:45:53.888988736 +0800 |
| 75 +++ zlib/contrib/minizip/zip.c 2016-05-13 17:32:21.510780073 +0800 |
| 76 @@ -26,7 +26,7 @@ |
| 77 #include <stdlib.h> |
| 78 #include <string.h> |
| 79 #include <time.h> |
| 80 -#include "zlib.h" |
| 81 +#include "third_party/zlib/zlib.h" |
| 82 #include "zip.h" |
| 83 |
| 84 #ifdef STDC |
| 85 diff -ru zlib-1.2.8/contrib/minizip/zip.h zlib/contrib/minizip/zip.h |
| 86 --- zlib-1.2.8/contrib/minizip/zip.h 2016-05-13 17:45:53.888988736 +0800 |
| 87 +++ zlib/contrib/minizip/zip.h 2016-05-13 17:32:21.510780073 +0800 |
| 88 @@ -47,7 +47,7 @@ |
| 89 //#define HAVE_BZIP2 |
| 90 |
| 91 #ifndef _ZLIB_H |
| 92 -#include "zlib.h" |
| 93 +#include "third_party/zlib/zlib.h" |
| 94 #endif |
| 95 |
| 96 #ifndef _ZLIBIOAPI_H |
| 97 diff -ru zlib-1.2.8/crc32.c zlib/crc32.c |
| 98 --- zlib-1.2.8/crc32.c 2016-05-13 17:45:53.888988736 +0800 |
| 99 +++ zlib/crc32.c 2016-05-13 17:32:21.454780493 +0800 |
| 100 @@ -28,6 +28,8 @@ |
| 101 # endif /* !DYNAMIC_CRC_TABLE */ |
| 102 #endif /* MAKECRCH */ |
| 103 |
| 104 +#include "deflate.h" |
| 105 +#include "x86.h" |
| 106 #include "zutil.h" /* for STDC and FAR definitions */ |
| 107 |
| 108 #define local static |
| 109 @@ -423,3 +425,28 @@ |
| 110 { |
| 111 return crc32_combine_(crc1, crc2, len2); |
| 112 } |
| 113 + |
| 114 +ZLIB_INTERNAL void crc_reset(deflate_state *const s) |
| 115 +{ |
| 116 + if (x86_cpu_enable_simd) { |
| 117 + crc_fold_init(s); |
| 118 + return; |
| 119 + } |
| 120 + s->strm->adler = crc32(0L, Z_NULL, 0); |
| 121 +} |
| 122 + |
| 123 +ZLIB_INTERNAL void crc_finalize(deflate_state *const s) |
| 124 +{ |
| 125 + if (x86_cpu_enable_simd) |
| 126 + s->strm->adler = crc_fold_512to32(s); |
| 127 +} |
| 128 + |
| 129 +ZLIB_INTERNAL void copy_with_crc(z_streamp strm, Bytef *dst, long size) |
| 130 +{ |
| 131 + if (x86_cpu_enable_simd) { |
| 132 + crc_fold_copy(strm->state, dst, strm->next_in, size); |
| 133 + return; |
| 134 + } |
| 135 + zmemcpy(dst, strm->next_in, size); |
| 136 + strm->adler = crc32(strm->adler, dst, size); |
| 137 +} |
| 138 diff -ru zlib-1.2.8/deflate.c zlib/deflate.c |
| 139 --- zlib-1.2.8/deflate.c 2016-05-13 17:45:53.888988736 +0800 |
| 140 +++ zlib/deflate.c 2016-05-13 17:32:21.454780493 +0800 |
| 141 @@ -49,7 +49,10 @@ |
| 142 |
| 143 /* @(#) $Id$ */ |
| 144 |
| 145 +#include <assert.h> |
| 146 + |
| 147 #include "deflate.h" |
| 148 +#include "x86.h" |
| 149 |
| 150 const char deflate_copyright[] = |
| 151 " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler "; |
| 152 @@ -70,26 +73,27 @@ |
| 153 finish_done /* finish done, accept no more input or output */ |
| 154 } block_state; |
| 155 |
| 156 -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); |
| 157 +typedef block_state (*compress_func) OF((deflate_state *s, int flush, |
| 158 + int clas)); |
| 159 /* Compression function. Returns the block state after the call. */ |
| 160 |
| 161 local void fill_window OF((deflate_state *s)); |
| 162 -local block_state deflate_stored OF((deflate_state *s, int flush)); |
| 163 -local block_state deflate_fast OF((deflate_state *s, int flush)); |
| 164 +local block_state deflate_stored OF((deflate_state *s, int flush, int clas)); |
| 165 +local block_state deflate_fast OF((deflate_state *s, int flush, int clas)); |
| 166 #ifndef FASTEST |
| 167 -local block_state deflate_slow OF((deflate_state *s, int flush)); |
| 168 +local block_state deflate_slow OF((deflate_state *s, int flush, int clas)); |
| 169 #endif |
| 170 local block_state deflate_rle OF((deflate_state *s, int flush)); |
| 171 local block_state deflate_huff OF((deflate_state *s, int flush)); |
| 172 local void lm_init OF((deflate_state *s)); |
| 173 local void putShortMSB OF((deflate_state *s, uInt b)); |
| 174 local void flush_pending OF((z_streamp strm)); |
| 175 -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); |
| 176 + |
| 177 #ifdef ASMV |
| 178 void match_init OF((void)); /* asm code initialization */ |
| 179 - uInt longest_match OF((deflate_state *s, IPos cur_match)); |
| 180 + uInt longest_match OF((deflate_state *s, IPos cur_match, int clas)); |
| 181 #else |
| 182 -local uInt longest_match OF((deflate_state *s, IPos cur_match)); |
| 183 +local uInt longest_match OF((deflate_state *s, IPos cur_match, int clas)); |
| 184 #endif |
| 185 |
| 186 #ifdef DEBUG |
| 187 @@ -97,6 +101,23 @@ |
| 188 int length)); |
| 189 #endif |
| 190 |
| 191 +/* For fill_window_sse.c to use */ |
| 192 +ZLIB_INTERNAL int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); |
| 193 + |
| 194 +/* From crc32.c */ |
| 195 +extern void ZLIB_INTERNAL crc_reset(deflate_state *const s); |
| 196 +extern void ZLIB_INTERNAL crc_finalize(deflate_state *const s); |
| 197 +extern void ZLIB_INTERNAL copy_with_crc(z_streamp strm, Bytef *dst, long size); |
| 198 + |
| 199 +#ifdef _MSC_VER |
| 200 +#define INLINE __inline |
| 201 +#else |
| 202 +#define INLINE inline |
| 203 +#endif |
| 204 + |
| 205 +/* Inline optimisation */ |
| 206 +local INLINE Pos insert_string_sse(deflate_state *const s, const Pos str); |
| 207 + |
| 208 /* =========================================================================== |
| 209 * Local data |
| 210 */ |
| 211 @@ -166,7 +187,6 @@ |
| 212 */ |
| 213 #define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask) |
| 214 |
| 215 - |
| 216 /* =========================================================================== |
| 217 * Insert string str in the dictionary and set match_head to the previous head |
| 218 * of the hash chain (the most recent string with same hash key). Return |
| 219 @@ -177,17 +197,28 @@ |
| 220 * input characters and the first MIN_MATCH bytes of str are valid |
| 221 * (except for the last MIN_MATCH-1 bytes of the input file). |
| 222 */ |
| 223 +local INLINE Pos insert_string_c(deflate_state *const s, const Pos str) |
| 224 +{ |
| 225 + Pos ret; |
| 226 + |
| 227 + UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]); |
| 228 #ifdef FASTEST |
| 229 -#define INSERT_STRING(s, str, match_head) \ |
| 230 - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ |
| 231 - match_head = s->head[s->ins_h], \ |
| 232 - s->head[s->ins_h] = (Pos)(str)) |
| 233 + ret = s->head[s->ins_h]; |
| 234 #else |
| 235 -#define INSERT_STRING(s, str, match_head) \ |
| 236 - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ |
| 237 - match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ |
| 238 - s->head[s->ins_h] = (Pos)(str)) |
| 239 + ret = s->prev[str & s->w_mask] = s->head[s->ins_h]; |
| 240 #endif |
| 241 + s->head[s->ins_h] = str; |
| 242 + |
| 243 + return ret; |
| 244 +} |
| 245 + |
| 246 +local INLINE Pos insert_string(deflate_state *const s, const Pos str) |
| 247 +{ |
| 248 + if (x86_cpu_enable_simd) |
| 249 + return insert_string_sse(s, str); |
| 250 + return insert_string_c(s, str); |
| 251 +} |
| 252 + |
| 253 |
| 254 /* =========================================================================== |
| 255 * Initialize the hash table (avoiding 64K overflow for 16 bit systems). |
| 256 @@ -221,6 +252,7 @@ |
| 257 const char *version; |
| 258 int stream_size; |
| 259 { |
| 260 + unsigned window_padding = 8; |
| 261 deflate_state *s; |
| 262 int wrap = 1; |
| 263 static const char my_version[] = ZLIB_VERSION; |
| 264 @@ -230,6 +262,8 @@ |
| 265 * output size for (length,distance) codes is <= 24 bits. |
| 266 */ |
| 267 |
| 268 + x86_check_features(); |
| 269 + |
| 270 if (version == Z_NULL || version[0] != my_version[0] || |
| 271 stream_size != sizeof(z_stream)) { |
| 272 return Z_VERSION_ERROR; |
| 273 @@ -285,14 +319,22 @@ |
| 274 s->w_size = 1 << s->w_bits; |
| 275 s->w_mask = s->w_size - 1; |
| 276 |
| 277 - s->hash_bits = memLevel + 7; |
| 278 + if (x86_cpu_enable_simd) { |
| 279 + s->hash_bits = 15; |
| 280 + } else { |
| 281 + s->hash_bits = memLevel + 7; |
| 282 + } |
| 283 + |
| 284 s->hash_size = 1 << s->hash_bits; |
| 285 s->hash_mask = s->hash_size - 1; |
| 286 s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); |
| 287 |
| 288 - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); |
| 289 + s->window = (Bytef *) ZALLOC(strm, s->w_size + window_padding, 2*sizeof(Byt
e)); |
| 290 s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); |
| 291 s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); |
| 292 + s->class_bitmap = NULL; |
| 293 + zmemzero(&s->cookie_locations, sizeof(s->cookie_locations)); |
| 294 + strm->clas = 0; |
| 295 |
| 296 s->high_water = 0; /* nothing written to s->window yet */ |
| 297 |
| 298 @@ -406,6 +448,8 @@ |
| 299 s = (deflate_state *)strm->state; |
| 300 s->pending = 0; |
| 301 s->pending_out = s->pending_buf; |
| 302 + TRY_FREE(strm, s->class_bitmap); |
| 303 + s->class_bitmap = NULL; |
| 304 |
| 305 if (s->wrap < 0) { |
| 306 s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ |
| 307 @@ -690,7 +734,7 @@ |
| 308 if (s->status == INIT_STATE) { |
| 309 #ifdef GZIP |
| 310 if (s->wrap == 2) { |
| 311 - strm->adler = crc32(0L, Z_NULL, 0); |
| 312 + crc_reset(s); |
| 313 put_byte(s, 31); |
| 314 put_byte(s, 139); |
| 315 put_byte(s, 8); |
| 316 @@ -900,9 +944,26 @@ |
| 317 (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { |
| 318 block_state bstate; |
| 319 |
| 320 - bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : |
| 321 - (s->strategy == Z_RLE ? deflate_rle(s, flush) : |
| 322 - (*(configuration_table[s->level].func))(s, flush)); |
| 323 + if (strm->clas && s->class_bitmap == NULL) { |
| 324 + /* This is the first time that we have seen alternative class |
| 325 + * data. All data up till this point has been standard class. */ |
| 326 + s->class_bitmap = (Bytef*) ZALLOC(strm, s->w_size/4, sizeof(Byte)); |
| 327 + zmemzero(s->class_bitmap, s->w_size/4); |
| 328 + } |
| 329 + |
| 330 + if (strm->clas && s->strategy == Z_RLE) { |
| 331 + /* We haven't patched deflate_rle. */ |
| 332 + ERR_RETURN(strm, Z_BUF_ERROR); |
| 333 + } |
| 334 + |
| 335 + if (s->strategy == Z_HUFFMAN_ONLY) { |
| 336 + bstate = deflate_huff(s, flush); |
| 337 + } else if (s->strategy == Z_RLE) { |
| 338 + bstate = deflate_rle(s, flush); |
| 339 + } else { |
| 340 + bstate = (*(configuration_table[s->level].func)) |
| 341 + (s, flush, strm->clas); |
| 342 + } |
| 343 |
| 344 if (bstate == finish_started || bstate == finish_done) { |
| 345 s->status = FINISH_STATE; |
| 346 @@ -952,6 +1013,7 @@ |
| 347 /* Write the trailer */ |
| 348 #ifdef GZIP |
| 349 if (s->wrap == 2) { |
| 350 + crc_finalize(s); |
| 351 put_byte(s, (Byte)(strm->adler & 0xff)); |
| 352 put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); |
| 353 put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); |
| 354 @@ -999,6 +1061,7 @@ |
| 355 TRY_FREE(strm, strm->state->head); |
| 356 TRY_FREE(strm, strm->state->prev); |
| 357 TRY_FREE(strm, strm->state->window); |
| 358 + TRY_FREE(strm, strm->state->class_bitmap); |
| 359 |
| 360 ZFREE(strm, strm->state); |
| 361 strm->state = Z_NULL; |
| 362 @@ -1073,7 +1136,7 @@ |
| 363 * allocating a large strm->next_in buffer and copying from it. |
| 364 * (See also flush_pending()). |
| 365 */ |
| 366 -local int read_buf(strm, buf, size) |
| 367 +ZLIB_INTERNAL int read_buf(strm, buf, size) |
| 368 z_streamp strm; |
| 369 Bytef *buf; |
| 370 unsigned size; |
| 371 @@ -1085,15 +1148,17 @@ |
| 372 |
| 373 strm->avail_in -= len; |
| 374 |
| 375 - zmemcpy(buf, strm->next_in, len); |
| 376 - if (strm->state->wrap == 1) { |
| 377 - strm->adler = adler32(strm->adler, buf, len); |
| 378 - } |
| 379 #ifdef GZIP |
| 380 - else if (strm->state->wrap == 2) { |
| 381 - strm->adler = crc32(strm->adler, buf, len); |
| 382 + if (strm->state->wrap == 2) { |
| 383 + copy_with_crc(strm, buf, len); |
| 384 } |
| 385 + else |
| 386 #endif |
| 387 + { |
| 388 + zmemcpy(buf, strm->next_in, len); |
| 389 + if (strm->state->wrap == 1) |
| 390 + strm->adler = adler32(strm->adler, buf, len); |
| 391 + } |
| 392 strm->next_in += len; |
| 393 strm->total_in += len; |
| 394 |
| 395 @@ -1131,6 +1196,57 @@ |
| 396 #endif |
| 397 } |
| 398 |
| 399 +/* class_set sets bits [offset,offset+len) in s->class_bitmap to either 1 (if |
| 400 + * class != 0) or 0 (otherwise). */ |
| 401 +local void class_set(s, offset, len, clas) |
| 402 + deflate_state *s; |
| 403 + IPos offset; |
| 404 + uInt len; |
| 405 + int clas; |
| 406 +{ |
| 407 + IPos byte = offset >> 3; |
| 408 + IPos bit = offset & 7; |
| 409 + Bytef class_byte_value = clas ? 0xff : 0x00; |
| 410 + Bytef class_bit_value = clas ? 1 : 0; |
| 411 + static const Bytef mask[8] = {0xfe, 0xfd, 0xfb, 0xf7, |
| 412 + 0xef, 0xdf, 0xbf, 0x7f}; |
| 413 + |
| 414 + if (bit) { |
| 415 + while (len) { |
| 416 + s->class_bitmap[byte] &= mask[bit]; |
| 417 + s->class_bitmap[byte] |= class_bit_value << bit; |
| 418 + bit++; |
| 419 + len--; |
| 420 + if (bit == 8) { |
| 421 + bit = 0; |
| 422 + byte++; |
| 423 + break; |
| 424 + } |
| 425 + } |
| 426 + } |
| 427 + |
| 428 + while (len >= 8) { |
| 429 + s->class_bitmap[byte++] = class_byte_value; |
| 430 + len -= 8; |
| 431 + } |
| 432 + |
| 433 + while (len) { |
| 434 + s->class_bitmap[byte] &= mask[bit]; |
| 435 + s->class_bitmap[byte] |= class_bit_value << bit; |
| 436 + bit++; |
| 437 + len--; |
| 438 + } |
| 439 +} |
| 440 + |
| 441 +local int class_at(s, window_offset) |
| 442 + deflate_state *s; |
| 443 + IPos window_offset; |
| 444 +{ |
| 445 + IPos byte = window_offset >> 3; |
| 446 + IPos bit = window_offset & 7; |
| 447 + return (s->class_bitmap[byte] >> bit) & 1; |
| 448 +} |
| 449 + |
| 450 #ifndef FASTEST |
| 451 /* =========================================================================== |
| 452 * Set match_start to the longest match starting at the given string and |
| 453 @@ -1145,9 +1261,10 @@ |
| 454 /* For 80x86 and 680x0, an optimized version will be provided in match.asm or |
| 455 * match.S. The code will be functionally equivalent. |
| 456 */ |
| 457 -local uInt longest_match(s, cur_match) |
| 458 +local uInt longest_match(s, cur_match, clas) |
| 459 deflate_state *s; |
| 460 IPos cur_match; /* current match */ |
| 461 + int clas; |
| 462 { |
| 463 unsigned chain_length = s->max_chain_length;/* max hash chain length */ |
| 464 register Bytef *scan = s->window + s->strstart; /* current string */ |
| 465 @@ -1195,6 +1312,9 @@ |
| 466 do { |
| 467 Assert(cur_match < s->strstart, "no future"); |
| 468 match = s->window + cur_match; |
| 469 + /* If the matched data is in the wrong class, skip it. */ |
| 470 + if (s->class_bitmap && class_at(s, cur_match) != clas) |
| 471 + continue; |
| 472 |
| 473 /* Skip to next match if the match length cannot increase |
| 474 * or if the match length is less than 2. Note that the checks below |
| 475 @@ -1237,6 +1357,8 @@ |
| 476 len = (MAX_MATCH - 1) - (int)(strend-scan); |
| 477 scan = strend - (MAX_MATCH-1); |
| 478 |
| 479 +#error "UNALIGNED_OK hasn't been patched." |
| 480 + |
| 481 #else /* UNALIGNED_OK */ |
| 482 |
| 483 if (match[best_len] != scan_end || |
| 484 @@ -1253,15 +1375,23 @@ |
| 485 scan += 2, match++; |
| 486 Assert(*scan == *match, "match[2]?"); |
| 487 |
| 488 - /* We check for insufficient lookahead only every 8th comparison; |
| 489 - * the 256th check will be made at strstart+258. |
| 490 - */ |
| 491 - do { |
| 492 - } while (*++scan == *++match && *++scan == *++match && |
| 493 - *++scan == *++match && *++scan == *++match && |
| 494 - *++scan == *++match && *++scan == *++match && |
| 495 - *++scan == *++match && *++scan == *++match && |
| 496 - scan < strend); |
| 497 + if (!s->class_bitmap) { |
| 498 + /* We check for insufficient lookahead only every 8th comparison; |
| 499 + * the 256th check will be made at strstart+258. |
| 500 + */ |
| 501 + do { |
| 502 + } while (*++scan == *++match && *++scan == *++match && |
| 503 + *++scan == *++match && *++scan == *++match && |
| 504 + *++scan == *++match && *++scan == *++match && |
| 505 + *++scan == *++match && *++scan == *++match && |
| 506 + scan < strend); |
| 507 + } else { |
| 508 + /* We have to be mindful of the class of the data and not stray. */ |
| 509 + do { |
| 510 + } while (*++scan == *++match && |
| 511 + class_at(s, match - s->window) == clas && |
| 512 + scan < strend); |
| 513 + } |
| 514 |
| 515 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); |
| 516 |
| 517 @@ -1289,20 +1419,74 @@ |
| 518 } |
| 519 #endif /* ASMV */ |
| 520 |
| 521 +/* cookie_match is a replacement for longest_match in the case of cookie data. |
| 522 + * Here we only wish to match the entire value so trying the partial matches in |
| 523 + * longest_match is both wasteful and often fails to find the correct match. |
| 524 + * |
| 525 + * So we take the djb2 hash of the cookie and look up the last position for a |
| 526 + * match in a special hash table. */ |
| 527 +local uInt cookie_match(s, start, len) |
| 528 + deflate_state *s; |
| 529 + IPos start; |
| 530 + unsigned len; |
| 531 +{ |
| 532 + unsigned hash = 5381; |
| 533 + Bytef *str = s->window + start; |
| 534 + unsigned i; |
| 535 + IPos cookie_location; |
| 536 + |
| 537 + if (len >= MAX_MATCH || len == 0) |
| 538 + return 0; |
| 539 + |
| 540 + for (i = 0; i < len; i++) |
| 541 + hash = ((hash << 5) + hash) + str[i]; |
| 542 + |
| 543 + hash &= Z_COOKIE_HASH_MASK; |
| 544 + cookie_location = s->cookie_locations[hash]; |
| 545 + s->cookie_locations[hash] = start; |
| 546 + s->match_start = 0; |
| 547 + if (cookie_location && |
| 548 + (start - cookie_location) > len && |
| 549 + (start - cookie_location) < MAX_DIST(s) && |
| 550 + len <= s->lookahead) { |
| 551 + for (i = 0; i < len; i++) { |
| 552 + if (s->window[start+i] != s->window[cookie_location+i] || |
| 553 + class_at(s, cookie_location+i) != 1) { |
| 554 + return 0; |
| 555 + } |
| 556 + } |
| 557 + /* Check that we aren't matching a prefix of another cookie by ensuring |
| 558 + * that the final byte is either a semicolon (which cannot appear in a |
| 559 + * cookie value), or the match is followed by non-cookie data. */ |
| 560 + if (s->window[cookie_location+len-1] != ';' && |
| 561 + class_at(s, cookie_location+len) != 0) { |
| 562 + return 0; |
| 563 + } |
| 564 + s->match_start = cookie_location; |
| 565 + return len; |
| 566 + } |
| 567 + |
| 568 + return 0; |
| 569 +} |
| 570 + |
| 571 + |
| 572 #else /* FASTEST */ |
| 573 |
| 574 /* --------------------------------------------------------------------------- |
| 575 * Optimized version for FASTEST only |
| 576 */ |
| 577 -local uInt longest_match(s, cur_match) |
| 578 +local uInt longest_match(s, cur_match, clas) |
| 579 deflate_state *s; |
| 580 IPos cur_match; /* current match */ |
| 581 + int clas; |
| 582 { |
| 583 register Bytef *scan = s->window + s->strstart; /* current string */ |
| 584 register Bytef *match; /* matched string */ |
| 585 register int len; /* length of current match */ |
| 586 register Bytef *strend = s->window + s->strstart + MAX_MATCH; |
| 587 |
| 588 +#error "This code not patched" |
| 589 + |
| 590 /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. |
| 591 * It is easy to get rid of this optimization if necessary. |
| 592 */ |
| 593 @@ -1387,7 +1571,19 @@ |
| 594 * performed for at least two bytes (required for the zip translate_eol |
| 595 * option -- not supported here). |
| 596 */ |
| 597 -local void fill_window(s) |
| 598 +local void fill_window_c(deflate_state *s); |
| 599 + |
| 600 +local void fill_window(deflate_state *s) |
| 601 +{ |
| 602 + if (x86_cpu_enable_simd) { |
| 603 + fill_window_sse(s); |
| 604 + return; |
| 605 + } |
| 606 + |
| 607 + fill_window_c(s); |
| 608 +} |
| 609 + |
| 610 +local void fill_window_c(s) |
| 611 deflate_state *s; |
| 612 { |
| 613 register unsigned n, m; |
| 614 @@ -1447,6 +1643,21 @@ |
| 615 */ |
| 616 } while (--n); |
| 617 #endif |
| 618 + |
| 619 + for (n = 0; n < Z_COOKIE_HASH_SIZE; n++) { |
| 620 + if (s->cookie_locations[n] > wsize) { |
| 621 + s->cookie_locations[n] -= wsize; |
| 622 + } else { |
| 623 + s->cookie_locations[n] = 0; |
| 624 + } |
| 625 + } |
| 626 + |
| 627 + if (s->class_bitmap) { |
| 628 + zmemcpy(s->class_bitmap, s->class_bitmap + s->w_size/8, |
| 629 + s->w_size/8); |
| 630 + zmemzero(s->class_bitmap + s->w_size/8, s->w_size/8); |
| 631 + } |
| 632 + |
| 633 more += wsize; |
| 634 } |
| 635 if (s->strm->avail_in == 0) break; |
| 636 @@ -1465,6 +1676,9 @@ |
| 637 Assert(more >= 2, "more < 2"); |
| 638 |
| 639 n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); |
| 640 + if (s->class_bitmap != NULL) { |
| 641 + class_set(s, s->strstart + s->lookahead, n, s->strm->clas); |
| 642 + } |
| 643 s->lookahead += n; |
| 644 |
| 645 /* Initialize the hash value now that we have some input: */ |
| 646 @@ -1561,9 +1775,10 @@ |
| 647 * NOTE: this function should be optimized to avoid extra copying from |
| 648 * window to pending_buf. |
| 649 */ |
| 650 -local block_state deflate_stored(s, flush) |
| 651 +local block_state deflate_stored(s, flush, clas) |
| 652 deflate_state *s; |
| 653 int flush; |
| 654 + int clas; |
| 655 { |
| 656 /* Stored blocks are limited to 0xffff bytes, pending_buf is limited |
| 657 * to pending_buf_size, and each stored block has a 5 byte header: |
| 658 @@ -1625,13 +1840,19 @@ |
| 659 * new strings in the dictionary only for unmatched strings or for short |
| 660 * matches. It is used only for the fast compression options. |
| 661 */ |
| 662 -local block_state deflate_fast(s, flush) |
| 663 +local block_state deflate_fast(s, flush, clas) |
| 664 deflate_state *s; |
| 665 int flush; |
| 666 + int clas; |
| 667 { |
| 668 IPos hash_head; /* head of the hash chain */ |
| 669 int bflush; /* set if current block must be flushed */ |
| 670 |
| 671 + if (clas != 0) { |
| 672 + /* We haven't patched this code for alternative class data. */ |
| 673 + return Z_BUF_ERROR; |
| 674 + } |
| 675 + |
| 676 for (;;) { |
| 677 /* Make sure that we always have enough lookahead, except |
| 678 * at the end of the input file. We need MAX_MATCH bytes |
| 679 @@ -1651,7 +1872,7 @@ |
| 680 */ |
| 681 hash_head = NIL; |
| 682 if (s->lookahead >= MIN_MATCH) { |
| 683 - INSERT_STRING(s, s->strstart, hash_head); |
| 684 + hash_head = insert_string(s, s->strstart); |
| 685 } |
| 686 |
| 687 /* Find the longest match, discarding those <= prev_length. |
| 688 @@ -1662,7 +1883,7 @@ |
| 689 * of window index 0 (in particular we have to avoid a match |
| 690 * of the string with itself at the start of the input file). |
| 691 */ |
| 692 - s->match_length = longest_match (s, hash_head); |
| 693 + s->match_length = longest_match (s, hash_head, clas); |
| 694 /* longest_match() sets match_start */ |
| 695 } |
| 696 if (s->match_length >= MIN_MATCH) { |
| 697 @@ -1682,7 +1903,7 @@ |
| 698 s->match_length--; /* string at strstart already in table */ |
| 699 do { |
| 700 s->strstart++; |
| 701 - INSERT_STRING(s, s->strstart, hash_head); |
| 702 + hash_head = insert_string(s, s->strstart); |
| 703 /* strstart never exceeds WSIZE-MAX_MATCH, so there are |
| 704 * always MIN_MATCH bytes ahead. |
| 705 */ |
| 706 @@ -1727,12 +1948,25 @@ |
| 707 * evaluation for matches: a match is finally adopted only if there is |
| 708 * no better match at the next window position. |
| 709 */ |
| 710 -local block_state deflate_slow(s, flush) |
| 711 +local block_state deflate_slow(s, flush, clas) |
| 712 deflate_state *s; |
| 713 int flush; |
| 714 + int clas; |
| 715 { |
| 716 IPos hash_head; /* head of hash chain */ |
| 717 int bflush; /* set if current block must be flushed */ |
| 718 + uInt input_length ; |
| 719 + int first = 1; /* first says whether this is the first iteration |
| 720 + of the loop, below. */ |
| 721 + |
| 722 + if (clas == Z_CLASS_COOKIE) { |
| 723 + if (s->lookahead) { |
| 724 + /* Alternative class data must always be presented at the beginning |
| 725 + * of a block. */ |
| 726 + return Z_BUF_ERROR; |
| 727 + } |
| 728 + input_length = s->strm->avail_in; |
| 729 + } |
| 730 |
| 731 /* Process the input block. */ |
| 732 for (;;) { |
| 733 @@ -1754,7 +1988,7 @@ |
| 734 */ |
| 735 hash_head = NIL; |
| 736 if (s->lookahead >= MIN_MATCH) { |
| 737 - INSERT_STRING(s, s->strstart, hash_head); |
| 738 + hash_head = insert_string(s, s->strstart); |
| 739 } |
| 740 |
| 741 /* Find the longest match, discarding those <= prev_length. |
| 742 @@ -1762,13 +1996,18 @@ |
| 743 s->prev_length = s->match_length, s->prev_match = s->match_start; |
| 744 s->match_length = MIN_MATCH-1; |
| 745 |
| 746 - if (hash_head != NIL && s->prev_length < s->max_lazy_match && |
| 747 - s->strstart - hash_head <= MAX_DIST(s)) { |
| 748 + if (clas == Z_CLASS_COOKIE && first) { |
| 749 + s->match_length = cookie_match(s, s->strstart, input_length); |
| 750 + } else if (clas == Z_CLASS_STANDARD && |
| 751 + hash_head != NIL && |
| 752 + s->prev_length < s->max_lazy_match && |
| 753 + s->strstart - hash_head <= MAX_DIST(s)) { |
| 754 /* To simplify the code, we prevent matches with the string |
| 755 * of window index 0 (in particular we have to avoid a match |
| 756 * of the string with itself at the start of the input file). |
| 757 */ |
| 758 - s->match_length = longest_match (s, hash_head); |
| 759 + s->match_length = longest_match (s, hash_head, clas); |
| 760 + |
| 761 /* longest_match() sets match_start */ |
| 762 |
| 763 if (s->match_length <= 5 && (s->strategy == Z_FILTERED |
| 764 @@ -1787,7 +2026,20 @@ |
| 765 /* If there was a match at the previous step and the current |
| 766 * match is not better, output the previous match: |
| 767 */ |
| 768 - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { |
| 769 + first = 0; |
| 770 + if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length && |
| 771 + /* We will only accept an exact match for Z_CLASS_COOKIE data and |
| 772 + * we won't match Z_CLASS_HUFFMAN_ONLY data at all. */ |
| 773 + (clas == Z_CLASS_STANDARD || (clas == Z_CLASS_COOKIE && |
| 774 + s->prev_length == input_length && |
| 775 + s->prev_match > 0 && |
| 776 + /* We require that a Z_CLASS_COOKIE match be |
| 777 + * preceded by either a semicolon (which cannot be |
| 778 + * part of a cookie), or non-cookie data. This is |
| 779 + * to prevent a cookie from being a suffix of |
| 780 + * another. */ |
| 781 + (class_at(s, s->prev_match-1) == Z_CLASS_STANDARD |
| |
| 782 + *(s->window + s->prev_match-1) == ';')))) { |
| 783 uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; |
| 784 /* Do not insert strings in hash table beyond this. */ |
| 785 |
| 786 @@ -1805,7 +2057,7 @@ |
| 787 s->prev_length -= 2; |
| 788 do { |
| 789 if (++s->strstart <= max_insert) { |
| 790 - INSERT_STRING(s, s->strstart, hash_head); |
| 791 + hash_head = insert_string(s, s->strstart); |
| 792 } |
| 793 } while (--s->prev_length != 0); |
| 794 s->match_available = 0; |
| 795 @@ -1965,3 +2217,37 @@ |
| 796 FLUSH_BLOCK(s, 0); |
| 797 return block_done; |
| 798 } |
| 799 + |
| 800 +/* Safe to inline this as GCC/clang will use inline asm and Visual Studio will |
| 801 + * use intrinsic without extra params |
| 802 + */ |
| 803 +local INLINE Pos insert_string_sse(deflate_state *const s, const Pos str) |
| 804 +{ |
| 805 + Pos ret; |
| 806 + unsigned *ip, val, h = 0; |
| 807 + |
| 808 + ip = (unsigned *)&s->window[str]; |
| 809 + val = *ip; |
| 810 + |
| 811 + if (s->level >= 6) |
| 812 + val &= 0xFFFFFF; |
| 813 + |
| 814 +/* Windows clang should use inline asm */ |
| 815 +#if defined(_MSC_VER) && !defined(__clang__) |
| 816 + h = _mm_crc32_u32(h, val); |
| 817 +#elif defined(__i386__) || defined(__amd64__) |
| 818 + __asm__ __volatile__ ( |
| 819 + "crc32 %1,%0\n\t" |
| 820 + : "+r" (h) |
| 821 + : "r" (val) |
| 822 + ); |
| 823 +#else |
| 824 + /* This should never happen */ |
| 825 + assert(0); |
| 826 +#endif |
| 827 + |
| 828 + ret = s->head[h & s->hash_mask]; |
| 829 + s->head[h & s->hash_mask] = str; |
| 830 + s->prev[str & s->w_mask] = ret; |
| 831 + return ret; |
| 832 +} |
| 833 diff -ru zlib-1.2.8/deflate.h zlib/deflate.h |
| 834 --- zlib-1.2.8/deflate.h 2016-05-13 17:45:53.888988736 +0800 |
| 835 +++ zlib/deflate.h 2016-05-13 17:32:21.454780493 +0800 |
| 836 @@ -94,6 +94,9 @@ |
| 837 * save space in the various tables. IPos is used only for parameter passing. |
| 838 */ |
| 839 |
| 840 +#define Z_COOKIE_HASH_SIZE 256 |
| 841 +#define Z_COOKIE_HASH_MASK (Z_COOKIE_HASH_SIZE-1) |
| 842 + |
| 843 typedef struct internal_state { |
| 844 z_streamp strm; /* pointer back to this zlib stream */ |
| 845 int status; /* as the name implies */ |
| 846 @@ -107,6 +110,8 @@ |
| 847 Byte method; /* can only be DEFLATED */ |
| 848 int last_flush; /* value of flush param for previous deflate call */ |
| 849 |
| 850 + unsigned zalign(16) crc0[4 * 5]; |
| 851 + |
| 852 /* used by deflate.c: */ |
| 853 |
| 854 uInt w_size; /* LZ77 window size (32K by default) */ |
| 855 @@ -142,6 +147,8 @@ |
| 856 uInt hash_mask; /* hash_size-1 */ |
| 857 |
| 858 uInt hash_shift; |
| 859 + Bytef *class_bitmap; /* bitmap of class for each byte in window */ |
| 860 + IPos cookie_locations[Z_COOKIE_HASH_SIZE]; |
| 861 /* Number of bits by which ins_h must be shifted at each input |
| 862 * step. It must be such that after MIN_MATCH steps, the oldest |
| 863 * byte no longer takes part in the hash key, that is: |
| 864 @@ -343,4 +350,14 @@ |
| 865 flush = _tr_tally(s, distance, length) |
| 866 #endif |
| 867 |
| 868 +/* Functions that are SIMD optimised on x86 */ |
| 869 +void ZLIB_INTERNAL crc_fold_init(deflate_state* const s); |
| 870 +void ZLIB_INTERNAL crc_fold_copy(deflate_state* const s, |
| 871 + unsigned char* dst, |
| 872 + const unsigned char* src, |
| 873 + long len); |
| 874 +unsigned ZLIB_INTERNAL crc_fold_512to32(deflate_state* const s); |
| 875 + |
| 876 +void ZLIB_INTERNAL fill_window_sse(deflate_state* s); |
| 877 + |
| 878 #endif /* DEFLATE_H */ |
| 879 diff -ru zlib-1.2.8/gzlib.c zlib/gzlib.c |
| 880 --- zlib-1.2.8/gzlib.c 2016-05-13 17:45:53.888988736 +0800 |
| 881 +++ zlib/gzlib.c 2016-05-13 17:32:21.454780493 +0800 |
| 882 @@ -6,14 +6,12 @@ |
6 #include "gzguts.h" | 883 #include "gzguts.h" |
7 | 884 |
| 885 #if defined(_WIN32) && !defined(__BORLANDC__) |
| 886 -# define LSEEK _lseeki64 |
| 887 -#else |
8 -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 | 888 -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 |
9 +#if defined(_WIN32) | |
10 +# define LSEEK (z_off64_t)_lseeki64 | 889 +# define LSEEK (z_off64_t)_lseeki64 |
11 +#elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 | 890 +#elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 |
12 # define LSEEK lseek64 | 891 # define LSEEK lseek64 |
13 #else | 892 #else |
14 # define LSEEK lseek | 893 # define LSEEK lseek |
15 diff -ru zlib-1.2.5/mozzconf.h zlib/mozzconf.h | 894 #endif |
16 --- zlib-1.2.5/mozzconf.h» 2011-12-15 18:10:49.000000000 +0800 | 895 -#endif |
17 +++ zlib/mozzconf.h» 2011-12-16 16:08:00.000000000 +0800 | 896 |
18 @@ -0,0 +1,168 @@ | 897 /* Local functions */ |
19 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 898 local void gz_reset OF((gz_statep)); |
20 +/* ***** BEGIN LICENSE BLOCK ***** | 899 diff -ru zlib-1.2.8/zconf.h zlib/zconf.h |
21 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 900 --- zlib-1.2.8/zconf.h» 2016-05-13 17:45:53.888988736 +0800 |
22 + * | 901 +++ zlib/zconf.h» 2016-05-13 17:32:21.454780493 +0800 |
23 + * The contents of this file are subject to the Mozilla Public License Version | |
24 + * 1.1 (the "License"); you may not use this file except in compliance with | |
25 + * the License. You may obtain a copy of the License at | |
26 + * http://www.mozilla.org/MPL/ | |
27 + * | |
28 + * Software distributed under the License is distributed on an "AS IS" basis, | |
29 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
30 + * for the specific language governing rights and limitations under the | |
31 + * License. | |
32 + * | |
33 + * The Original Code is the mozilla zlib configuration. | |
34 + * | |
35 + * The Initial Developer of the Original Code is IBM Corporation. | |
36 + * Portions created by the Initial Developer are Copyright (C) 2004 | |
37 + * the Initial Developer. All Rights Reserved. | |
38 + * | |
39 + * Contributor(s): | |
40 + * | |
41 + * Alternatively, the contents of this file may be used under the terms of | |
42 + * either of the GNU General Public License Version 2 or later (the "GPL"), | |
43 + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | |
44 + * in which case the provisions of the GPL or the LGPL are applicable instead | |
45 + * of those above. If you wish to allow use of your version of this file only | |
46 + * under the terms of either the GPL or the LGPL, and not to allow others to | |
47 + * use your version of this file under the terms of the MPL, indicate your | |
48 + * decision by deleting the provisions above and replace them with the notice | |
49 + * and other provisions required by the GPL or the LGPL. If you do not delete | |
50 + * the provisions above, a recipient may use your version of this file under | |
51 + * the terms of any one of the MPL, the GPL or the LGPL. | |
52 + * | |
53 + * ***** END LICENSE BLOCK ***** */ | |
54 + | |
55 +#ifndef MOZZCONF_H | |
56 +#define MOZZCONF_H | |
57 + | |
58 +#if defined(XP_WIN) && defined(ZLIB_DLL) && !defined(MOZ_ENABLE_LIBXUL) | |
59 +#undef ZLIB_DLL | |
60 +#endif | |
61 + | |
62 +#ifdef HAVE_VISIBILITY_ATTRIBUTE | |
63 +#define ZEXTERN __attribute__((visibility ("default"))) extern | |
64 +#endif | |
65 + | |
66 +/* Exported Symbols */ | |
67 +#define zlibVersion MOZ_Z_zlibVersion | |
68 +#define deflate MOZ_Z_deflate | |
69 +#define deflateEnd MOZ_Z_deflateEnd | |
70 +#define inflate MOZ_Z_inflate | |
71 +#define inflateEnd MOZ_Z_inflateEnd | |
72 +#define deflateSetDictionary MOZ_Z_deflateSetDictionary | |
73 +#define deflateCopy MOZ_Z_deflateCopy | |
74 +#define deflateReset MOZ_Z_deflateReset | |
75 +#define deflateParams MOZ_Z_deflateParams | |
76 +#define deflateBound MOZ_Z_deflateBound | |
77 +#define deflatePrime MOZ_Z_deflatePrime | |
78 +#define inflateSetDictionary MOZ_Z_inflateSetDictionary | |
79 +#define inflateSync MOZ_Z_inflateSync | |
80 +#define inflateCopy MOZ_Z_inflateCopy | |
81 +#define inflateReset MOZ_Z_inflateReset | |
82 +#define inflateBack MOZ_Z_inflateBack | |
83 +#define inflateBackEnd MOZ_Z_inflateBackEnd | |
84 +#define zlibCompileFlags MOZ_Z_zlibCompileFlags | |
85 +#define compress MOZ_Z_compress | |
86 +#define compress2 MOZ_Z_compress2 | |
87 +#define compressBound MOZ_Z_compressBound | |
88 +#define uncompress MOZ_Z_uncompress | |
89 +#define gzopen MOZ_Z_gzopen | |
90 +#define gzdopen MOZ_Z_gzdopen | |
91 +#define gzsetparams MOZ_Z_gzsetparams | |
92 +#define gzread MOZ_Z_gzread | |
93 +#define gzwrite MOZ_Z_gzwrite | |
94 +#define gzprintf MOZ_Z_gzprintf | |
95 +#define gzputs MOZ_Z_gzputs | |
96 +#define gzgets MOZ_Z_gzgets | |
97 +#define gzputc MOZ_Z_gzputc | |
98 +#define gzgetc MOZ_Z_gzgetc | |
99 +#define gzungetc MOZ_Z_gzungetc | |
100 +#define gzflush MOZ_Z_gzflush | |
101 +#define gzseek MOZ_Z_gzseek | |
102 +#define gzrewind MOZ_Z_gzrewind | |
103 +#define gztell MOZ_Z_gztell | |
104 +#define gzeof MOZ_Z_gzeof | |
105 +#define gzclose MOZ_Z_gzclose | |
106 +#define gzerror MOZ_Z_gzerror | |
107 +#define gzclearerr MOZ_Z_gzclearerr | |
108 +#define adler32 MOZ_Z_adler32 | |
109 +#define crc32 MOZ_Z_crc32 | |
110 +#define deflateInit_ MOZ_Z_deflateInit_ | |
111 +#define deflateInit2_ MOZ_Z_deflateInit2_ | |
112 +#define inflateInit_ MOZ_Z_inflateInit_ | |
113 +#define inflateInit2_ MOZ_Z_inflateInit2_ | |
114 +#define inflateBackInit_ MOZ_Z_inflateBackInit_ | |
115 +#define inflateSyncPoint MOZ_Z_inflateSyncPoint | |
116 +#define get_crc_table MOZ_Z_get_crc_table | |
117 +#define zError MOZ_Z_zError | |
118 + | |
119 +/* Extra global symbols */ | |
120 +#define _dist_code MOZ_Z__dist_code | |
121 +#define _length_code MOZ_Z__length_code | |
122 +#define _tr_align MOZ_Z__tr_align | |
123 +#define _tr_flush_block MOZ_Z__tr_flush_block | |
124 +#define _tr_init MOZ_Z__tr_init | |
125 +#define _tr_stored_block MOZ_Z__tr_stored_block | |
126 +#define _tr_tally MOZ_Z__tr_tally | |
127 +#define deflate_copyright MOZ_Z_deflate_copyright | |
128 +#define inflate_copyright MOZ_Z_inflate_copyright | |
129 +#define inflate_fast MOZ_Z_inflate_fast | |
130 +#define inflate_table MOZ_Z_inflate_table | |
131 +#define z_errmsg MOZ_Z_z_errmsg | |
132 +#define zcalloc MOZ_Z_zcalloc | |
133 +#define zcfree MOZ_Z_zcfree | |
134 +#define alloc_func MOZ_Z_alloc_func | |
135 +#define free_func MOZ_Z_free_func | |
136 +#define in_func MOZ_Z_in_func | |
137 +#define out_func MOZ_Z_out_func | |
138 + | |
139 +/* New as of libpng-1.2.3 */ | |
140 +#define adler32_combine MOZ_Z_adler32_combine | |
141 +#define crc32_combine MOZ_Z_crc32_combine | |
142 +#define deflateSetHeader MOZ_Z_deflateSetHeader | |
143 +#define deflateTune MOZ_Z_deflateTune | |
144 +#define gzdirect MOZ_Z_gzdirect | |
145 +#define inflatePrime MOZ_Z_inflatePrime | |
146 +#define inflateGetHeader MOZ_Z_inflateGetHeader | |
147 + | |
148 +/* New as of zlib 1.2.5 */ | |
149 +#define gzoffset MOZ_Z_gzoffset | |
150 +#define gzopen64 MOZ_Z_gzopen64 | |
151 +#define gzseek64 MOZ_Z_gzseek64 | |
152 +#define gztell64 MOZ_Z_gztell64 | |
153 +#define gzoffset64 MOZ_Z_gzoffset64 | |
154 +#define adler32_combine64 MOZ_Z_adler32_combine64 | |
155 +#define crc32_combine64 MOZ_Z_crc32_combine64 | |
156 +#define gz_error MOZ_Z_gz_error | |
157 +#define gz_intmax MOZ_Z_gz_intmax | |
158 +#define gz_strwinerror MOZ_Z_gz_strwinerror | |
159 +#define gzbuffer MOZ_Z_gzbuffer | |
160 +#define gzclose_r MOZ_Z_gzclose_r | |
161 +#define gzclose_w MOZ_Z_gzclose_w | |
162 +#define inflateMark MOZ_Z_inflateMark | |
163 +#define inflateReset2 MOZ_Z_inflateReset2 | |
164 +#define inflateUndermine MOZ_Z_inflateUndermine | |
165 +#define charf MOZ_Z_charf | |
166 +#define gzFile MOZ_Z_gzFile | |
167 +#define gz_header MOZ_Z_gz_header | |
168 +#define gz_headerp MOZ_Z_gz_headerp | |
169 +#define intf MOZ_Z_intf | |
170 +#define uInt MOZ_Z_uInt | |
171 +#define uIntf MOZ_Z_uIntf | |
172 +#define uLong MOZ_Z_uLong | |
173 +#define uLongf MOZ_Z_uLongf | |
174 +#define voidp MOZ_Z_voidp | |
175 +#define voidpc MOZ_Z_voidpc | |
176 +#define voidpf MOZ_Z_voidpf | |
177 +#define gz_header_s MOZ_Z_gz_header_s | |
178 +#define internal_state MOZ_Z_internal_state | |
179 + | |
180 +/* Mangle Byte types except on Mac. */ | |
181 +#if !defined(__MACTYPES__) | |
182 +#define Byte MOZ_Z_Byte | |
183 +#define Bytef MOZ_Z_Bytef | |
184 +#endif | |
185 + | |
186 +#endif | |
187 diff -ru zlib-1.2.5/zconf.h zlib/zconf.h | |
188 --- zlib-1.2.5/zconf.h» 2010-04-19 01:58:06.000000000 +0800 | |
189 +++ zlib/zconf.h» 2011-12-14 08:06:37.000000000 +0800 | |
190 @@ -8,6 +8,9 @@ | 902 @@ -8,6 +8,9 @@ |
191 #ifndef ZCONF_H | 903 #ifndef ZCONF_H |
192 #define ZCONF_H | 904 #define ZCONF_H |
193 | 905 |
194 +/* This include does prefixing as below, but with an updated set of names */ | 906 +/* This include does prefixing as below, but with an updated set of names */ |
195 +#include "mozzconf.h" | 907 +#include "mozzconf.h" |
196 + | 908 + |
197 /* | 909 /* |
198 * If you *really* need a unique prefix for all types and library functions, | 910 * If you *really* need a unique prefix for all types and library functions, |
199 * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. | 911 * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. |
200 @@ -359,7 +359,7 @@ typedef uLong FAR uLongf; | 912 @@ -408,7 +411,7 @@ |
201 typedef Byte *voidp; | 913 typedef unsigned long z_crc_t; |
202 #endif | 914 #endif |
203 | 915 |
204 -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ | 916 -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ |
205 +#if !defined(_WIN32) | 917 +#if !defined(_WIN32) |
206 # define Z_HAVE_UNISTD_H | 918 # define Z_HAVE_UNISTD_H |
207 #endif | 919 #endif |
208 | 920 |
209 --- zlib-1.2.5/zlib.h» 2010-04-20 12:12:48.000000000 +0800 | 921 diff -ru zlib-1.2.8/zlib.h zlib/zlib.h |
210 +++ zlib/zlib.h»2013-04-06 16:08:48.000000000 +0800 | 922 --- zlib-1.2.8/zlib.h» 2016-05-13 17:45:53.888988736 +0800 |
211 @@ -1572,11 +1572,29 @@ | 923 +++ zlib/zlib.h»2016-05-13 18:32:20.751343000 +0800 |
| 924 @@ -101,6 +101,7 @@ |
| 925 int data_type; /* best guess about the data type: binary or text */ |
| 926 uLong adler; /* adler32 value of the uncompressed data */ |
| 927 uLong reserved; /* reserved for future use */ |
| 928 + int clas; |
| 929 } z_stream; |
| 930 |
| 931 typedef z_stream FAR *z_streamp; |
| 932 @@ -207,6 +208,10 @@ |
| 933 |
| 934 #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ |
| 935 |
| 936 +#define Z_CLASS_STANDARD 0 |
| 937 +#define Z_CLASS_COOKIE 1 |
| 938 +#define Z_CLASS_HUFFMAN_ONLY 2 |
| 939 + |
| 940 #define zlib_version zlibVersion() |
| 941 /* for compatibility with versions < 1.0.2 */ |
| 942 |
| 943 @@ -1678,8 +1683,14 @@ |
| 944 # define z_gzgetc(g) \ |
| 945 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) |
| 946 #else |
| 947 -# define gzgetc(g) \ |
| 948 +# ifdef MOZZCONF_H |
| 949 +# undef gzgetc |
| 950 +# define gzgetc(g) \ |
| 951 + ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : MOZ_Z_gzgetc
(g)) |
| 952 +# else |
| 953 +# define gzgetc(g) \ |
| 954 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) |
| 955 +# endif |
212 #endif | 956 #endif |
213 | 957 |
214 #if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 | 958 /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or |
215 +# ifdef gzopen | 959 @@ -1706,11 +1717,29 @@ |
216 +# undef gzopen | 960 # define z_adler32_combine z_adler32_combine64 |
| 961 # define z_crc32_combine z_crc32_combine64 |
| 962 # else |
| 963 +# ifdef gzopen |
| 964 +# undef gzopen |
| 965 +# endif |
| 966 # define gzopen gzopen64 |
| 967 +# ifdef gzseek |
| 968 +# undef gzseek |
| 969 +# endif |
| 970 # define gzseek gzseek64 |
| 971 +# ifdef gztell |
| 972 +# undef gztell |
| 973 +# endif |
| 974 # define gztell gztell64 |
| 975 +# ifdef gzoffset |
| 976 +# undef gzoffset |
| 977 +# endif |
| 978 # define gzoffset gzoffset64 |
| 979 +# ifdef adler32_combine |
| 980 +# undef adler32_combine |
| 981 +# endif |
| 982 # define adler32_combine adler32_combine64 |
| 983 +# ifdef crc32_combine |
| 984 +# undef crc32_combine |
| 985 +# endif |
| 986 # define crc32_combine crc32_combine64 |
| 987 # endif |
| 988 # ifndef Z_LARGE64 |
| 989 @@ -1720,6 +1749,13 @@ |
| 990 ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); |
| 991 ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); |
| 992 ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); |
| 993 +# else |
| 994 + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); |
| 995 + ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); |
| 996 + ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); |
| 997 + ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); |
| 998 + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); |
| 999 + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); |
| 1000 # endif |
| 1001 #else |
| 1002 ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); |
| 1003 diff -ru zlib-1.2.8/zutil.h zlib/zutil.h |
| 1004 --- zlib-1.2.8/zutil.h» 2016-05-13 17:45:53.888988736 +0800 |
| 1005 +++ zlib/zutil.h» 2016-05-13 17:32:21.454780493 +0800 |
| 1006 @@ -28,6 +28,21 @@ |
| 1007 # include <string.h> |
| 1008 # include <stdlib.h> |
| 1009 #endif |
| 1010 +#ifdef NO_ERRNO_H |
| 1011 +# ifdef _WIN32_WCE |
| 1012 + /* The Microsoft C Run-Time Library for Windows CE doesn't have |
| 1013 + * errno. We define it as a global variable to simplify porting. |
| 1014 + * Its value is always 0 and should not be used. We rename it to |
| 1015 + * avoid conflict with other libraries that use the same workaround. |
| 1016 + */ |
| 1017 +# define errno z_errno |
| 1018 +# endif |
| 1019 + extern int errno; |
| 1020 +#else |
| 1021 +# ifndef _WIN32_WCE |
| 1022 +# include <errno.h> |
217 +# endif | 1023 +# endif |
218 # define gzopen gzopen64 | 1024 +#endif |
219 +# ifdef gzseek | 1025 |
220 +# undef gzseek | 1026 #ifdef Z_SOLO |
221 +# endif | 1027 typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ |
222 # define gzseek gzseek64 | 1028 @@ -135,6 +150,12 @@ |
223 +# ifdef gztell | 1029 # define OS_CODE 0x0a |
224 +# undef gztell | 1030 #endif |
225 +# endif | 1031 |
226 # define gztell gztell64 | 1032 +#ifdef _MSC_VER |
227 +# ifdef gzoffset | 1033 +#define zalign(x) __declspec(align(x)) |
228 +# undef gzoffset | 1034 +#else |
229 +# endif | 1035 +#define zalign(x) __attribute__((aligned((x)))) |
230 # define gzoffset gzoffset64 | 1036 +#endif |
231 +# ifdef adler32_combine | 1037 + |
232 +# undef adler32_combine | 1038 #ifdef WIN32 |
233 +# endif | 1039 # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ |
234 # define adler32_combine adler32_combine64 | 1040 # define OS_CODE 0x0b |
235 +# ifdef crc32_combine | |
236 +# undef crc32_combine | |
237 +# endif | |
238 # define crc32_combine crc32_combine64 | |
239 # ifdef _LARGEFILE64_SOURCE | |
240 ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | |
OLD | NEW |