1diff --git a/contrib/minizip/ioapi.h b/contrib/minizip/ioapi.h 2index 8dcbdb06e35a..c1b7a54847f5 100644 3--- a/contrib/minizip/ioapi.h 4+++ b/contrib/minizip/ioapi.h 5@@ -43,7 +43,7 @@ 6 7 #include <stdio.h> 8 #include <stdlib.h> 9-#include "zlib.h" 10+#include "third_party/zlib/zlib.h" 11 12 #if defined(USE_FILE32API) 13 #define fopen64 fopen 14diff --git a/contrib/minizip/iowin32.c b/contrib/minizip/iowin32.c 15index 274f39eb1dd2..246ceb91a139 100644 16--- a/contrib/minizip/iowin32.c 17+++ b/contrib/minizip/iowin32.c 18@@ -26,12 +26,19 @@ 19 #endif 20 21 22+#ifdef _WIN32_WINNT 23+#undef _WIN32_WINNT 24+#define _WIN32_WINNT 0x601 25+#endif 26+ 27+#if _WIN32_WINNT >= _WIN32_WINNT_WIN8 28 // see Include/shared/winapifamily.h in the Windows Kit 29 #if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API))) 30 #if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP) 31 #define IOWIN32_USING_WINRT_API 1 32 #endif 33 #endif 34+#endif 35 36 voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode)); 37 uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 38diff --git a/contrib/minizip/mztools.c b/contrib/minizip/mztools.c 39index 96891c2e0b71..8bf9cca32633 100644 40--- a/contrib/minizip/mztools.c 41+++ b/contrib/minizip/mztools.c 42@@ -8,7 +8,7 @@ 43 #include <stdio.h> 44 #include <stdlib.h> 45 #include <string.h> 46-#include "zlib.h" 47+#include "third_party/zlib/zlib.h" 48 #include "unzip.h" 49 50 #define READ_8(adr) ((unsigned char)*(adr)) 51diff --git a/contrib/minizip/mztools.h b/contrib/minizip/mztools.h 52index a49a426ec2fc..f295ffeda6af 100644 53--- a/contrib/minizip/mztools.h 54+++ b/contrib/minizip/mztools.h 55@@ -12,7 +12,7 @@ extern "C" { 56 #endif 57 58 #ifndef _ZLIB_H 59-#include "zlib.h" 60+#include "third_party/zlib/zlib.h" 61 #endif 62 63 #include "unzip.h" 64diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c 65index bcfb9416ec35..199b4723fcfc 100644 66--- a/contrib/minizip/unzip.c 67+++ b/contrib/minizip/unzip.c 68@@ -72,7 +72,7 @@ 69 #define NOUNCRYPT 70 #endif 71 72-#include "zlib.h" 73+#include "third_party/zlib/zlib.h" 74 #include "unzip.h" 75 76 #ifdef STDC 77@@ -1705,11 +1705,6 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) 78 79 pfile_in_zip_read_info->stream.avail_out = (uInt)len; 80 81- if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && 82- (!(pfile_in_zip_read_info->raw))) 83- pfile_in_zip_read_info->stream.avail_out = 84- (uInt)pfile_in_zip_read_info->rest_read_uncompressed; 85- 86 if ((len>pfile_in_zip_read_info->rest_read_compressed+ 87 pfile_in_zip_read_info->stream.avail_in) && 88 (pfile_in_zip_read_info->raw)) 89diff --git a/contrib/minizip/unzip.h b/contrib/minizip/unzip.h 90index 2104e3915074..3c0143529b91 100644 91--- a/contrib/minizip/unzip.h 92+++ b/contrib/minizip/unzip.h 93@@ -48,7 +48,7 @@ extern "C" { 94 #endif 95 96 #ifndef _ZLIB_H 97-#include "zlib.h" 98+#include "third_party/zlib/zlib.h" 99 #endif 100 101 #ifndef _ZLIBIOAPI_H 102diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c 103index 44e88a9cb989..65c0c7251843 100644 104--- a/contrib/minizip/zip.c 105+++ b/contrib/minizip/zip.c 106@@ -26,7 +26,7 @@ 107 #include <stdlib.h> 108 #include <string.h> 109 #include <time.h> 110-#include "zlib.h" 111+#include "third_party/zlib/zlib.h" 112 #include "zip.h" 113 114 #ifdef STDC 115diff --git a/contrib/minizip/zip.h b/contrib/minizip/zip.h 116index 8aaebb623430..8c06c0aa7bb0 100644 117--- a/contrib/minizip/zip.h 118+++ b/contrib/minizip/zip.h 119@@ -47,7 +47,7 @@ extern "C" { 120 //#define HAVE_BZIP2 121 122 #ifndef _ZLIB_H 123-#include "zlib.h" 124+#include "third_party/zlib/zlib.h" 125 #endif 126 127 #ifndef _ZLIBIOAPI_H 128diff --git a/gzread.c b/gzread.c 129index 956b91ea7d9e..832d3ef98c59 100644 130--- a/gzread.c 131+++ b/gzread.c 132@@ -443,7 +443,11 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file) 133 # undef z_gzgetc 134 #else 135 # undef gzgetc 136+# ifdef Z_CR_PREFIX_SET 137+# define gzgetc Cr_z_gzgetc 138+# endif 139 #endif 140+ 141 int ZEXPORT gzgetc(file) 142 gzFile file; 143 { 144diff --git a/zconf.h b/zconf.h 145index 5e1d68a004e9..a7a815f575a7 100644 146--- a/zconf.h 147+++ b/zconf.h 148@@ -8,6 +8,10 @@ 149 #ifndef ZCONF_H 150 #define ZCONF_H 151 152+/* 153+ * This library is also built as a part of AOSP, which does not need to include 154+ * chromeconf.h. This config does not want chromeconf.h, so it can set this 155+ * macro to opt out. While this works today, there's no guarantee that building 156+ * zlib outside of Chromium keeps working in the future. 157+ */ 158+#if !defined(CHROMIUM_ZLIB_NO_CHROMECONF) 159+/* This include does prefixing as below, but with an updated set of names. Also 160+ * sets up export macros in component builds. */ 161+#include "chromeconf.h" 162+#endif 163+ 164 /* 165 * If you *really* need a unique prefix for all types and library functions, 166 * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 167@@ -431,7 +434,7 @@ typedef uLong FAR uLongf; 168 typedef unsigned long z_crc_t; 169 #endif 170 171-#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ 172+#if !defined(_WIN32) 173 # define Z_HAVE_UNISTD_H 174 #endif 175 176diff --git a/zlib.h b/zlib.h 177index f09cdaf1e054..99fd467f6b1a 100644 178--- a/zlib.h 179+++ b/zlib.h 180@@ -1824,6 +1824,11 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ 181 # undef z_gzgetc 182 # define z_gzgetc(g) \ 183 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) 184+#elif defined(Z_CR_PREFIX_SET) 185+# undef gzgetc 186+# define gzgetc(g) \ 187+ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) \ 188+ : (Cr_z_gzgetc)(g)) 189 #else 190 # define gzgetc(g) \ 191 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) 192@@ -1853,11 +1858,29 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ 193 # define z_adler32_combine z_adler32_combine64 194 # define z_crc32_combine z_crc32_combine64 195 # else 196+# ifdef gzopen 197+# undef gzopen 198+# endif 199 # define gzopen gzopen64 200+# ifdef gzseek 201+# undef gzseek 202+# endif 203 # define gzseek gzseek64 204+# ifdef gztell 205+# undef gztell 206+# endif 207 # define gztell gztell64 208+# ifdef gzoffset 209+# undef gzoffset 210+# endif 211 # define gzoffset gzoffset64 212+# ifdef adler32_combine 213+# undef adler32_combine 214+# endif 215 # define adler32_combine adler32_combine64 216+# ifdef crc32_combine 217+# undef crc32_combine 218+# endif 219 # define crc32_combine crc32_combine64 220 # endif 221 # ifndef Z_LARGE64 222diff --git a/zutil.h b/zutil.h 223index b079ea6a80f5..80375b8b6109 100644 224--- a/zutil.h 225+++ b/zutil.h 226@@ -28,6 +28,21 @@ 227 # include <string.h> 228 # include <stdlib.h> 229 #endif 230+#ifdef NO_ERRNO_H 231+# ifdef _WIN32_WCE 232+ /* The Microsoft C Run-Time Library for Windows CE doesn't have 233+ * errno. We define it as a global variable to simplify porting. 234+ * Its value is always 0 and should not be used. We rename it to 235+ * avoid conflict with other libraries that use the same workaround. 236+ */ 237+# define errno z_errno 238+# endif 239+ extern int errno; 240+#else 241+# ifndef _WIN32_WCE 242+# include <errno.h> 243+# endif 244+#endif 245 246 #ifdef Z_SOLO 247 typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ 248