1diff --git a/contrib/minizip/iowin32.c b/contrib/minizip/iowin32.c 2index 274f39eb1dd2..246ceb91a139 100644 3--- a/contrib/minizip/iowin32.c 4+++ b/contrib/minizip/iowin32.c 5@@ -26,12 +26,19 @@ 6 #endif 7 8 9+#ifdef _WIN32_WINNT 10+#undef _WIN32_WINNT 11+#define _WIN32_WINNT 0x601 12+#endif 13+ 14+#if _WIN32_WINNT >= _WIN32_WINNT_WIN8 15 // see Include/shared/winapifamily.h in the Windows Kit 16 #if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API))) 17 #if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP) 18 #define IOWIN32_USING_WINRT_API 1 19 #endif 20 #endif 21+#endif 22 23 voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode)); 24 uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 25diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c 26index bcfb9416ec35..199b4723fcfc 100644 27--- a/contrib/minizip/unzip.c 28+++ b/contrib/minizip/unzip.c 29@@ -1705,11 +1705,6 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) 30 31 pfile_in_zip_read_info->stream.avail_out = (uInt)len; 32 33- if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && 34- (!(pfile_in_zip_read_info->raw))) 35- pfile_in_zip_read_info->stream.avail_out = 36- (uInt)pfile_in_zip_read_info->rest_read_uncompressed; 37- 38 if ((len>pfile_in_zip_read_info->rest_read_compressed+ 39 pfile_in_zip_read_info->stream.avail_in) && 40 (pfile_in_zip_read_info->raw)) 41diff --git a/gzread.c b/gzread.c 42index 956b91ea7d9e..832d3ef98c59 100644 43--- a/gzread.c 44+++ b/gzread.c 45@@ -443,7 +443,11 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file) 46 # undef z_gzgetc 47 #else 48 # undef gzgetc 49+# ifdef Z_CR_PREFIX_SET 50+# define gzgetc Cr_z_gzgetc 51+# endif 52 #endif 53+ 54 int ZEXPORT gzgetc(file) 55 gzFile file; 56 { 57diff --git a/zconf.h b/zconf.h 58index 5e1d68a004e9..a7a815f575a7 100644 59--- a/zconf.h 60+++ b/zconf.h 61@@ -8,6 +8,10 @@ 62 #ifndef ZCONF_H 63 #define ZCONF_H 64 65+/* 66+ * This library is also built as a part of AOSP, which does not need to include 67+ * chromeconf.h. This config does not want chromeconf.h, so it can set this 68+ * macro to opt out. While this works today, there's no guarantee that building 69+ * zlib outside of Chromium keeps working in the future. 70+ */ 71+#if !defined(CHROMIUM_ZLIB_NO_CHROMECONF) 72+/* This include does prefixing as below, but with an updated set of names. Also 73+ * sets up export macros in component builds. */ 74+#include "chromeconf.h" 75+#endif 76+ 77 /* 78 * If you *really* need a unique prefix for all types and library functions, 79 * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 80@@ -431,7 +434,7 @@ typedef uLong FAR uLongf; 81 typedef unsigned long z_crc_t; 82 #endif 83 84-#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ 85+#if !defined(_WIN32) 86 # define Z_HAVE_UNISTD_H 87 #endif 88 89diff --git a/zlib.h b/zlib.h 90index f09cdaf1e054..99fd467f6b1a 100644 91--- a/zlib.h 92+++ b/zlib.h 93@@ -1824,6 +1824,11 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ 94 # undef z_gzgetc 95 # define z_gzgetc(g) \ 96 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) 97+#elif defined(Z_CR_PREFIX_SET) 98+# undef gzgetc 99+# define gzgetc(g) \ 100+ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) \ 101+ : (Cr_z_gzgetc)(g)) 102 #else 103 # define gzgetc(g) \ 104 ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) 105@@ -1853,11 +1858,29 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ 106 # define z_adler32_combine z_adler32_combine64 107 # define z_crc32_combine z_crc32_combine64 108 # else 109+# ifdef gzopen 110+# undef gzopen 111+# endif 112 # define gzopen gzopen64 113+# ifdef gzseek 114+# undef gzseek 115+# endif 116 # define gzseek gzseek64 117+# ifdef gztell 118+# undef gztell 119+# endif 120 # define gztell gztell64 121+# ifdef gzoffset 122+# undef gzoffset 123+# endif 124 # define gzoffset gzoffset64 125+# ifdef adler32_combine 126+# undef adler32_combine 127+# endif 128 # define adler32_combine adler32_combine64 129+# ifdef crc32_combine 130+# undef crc32_combine 131+# endif 132 # define crc32_combine crc32_combine64 133 # endif 134 # ifndef Z_LARGE64 135diff --git a/zutil.h b/zutil.h 136index b079ea6a80f5..80375b8b6109 100644 137--- a/zutil.h 138+++ b/zutil.h 139@@ -28,6 +28,21 @@ 140 # include <string.h> 141 # include <stdlib.h> 142 #endif 143+#ifdef NO_ERRNO_H 144+# ifdef _WIN32_WCE 145+ /* The Microsoft C Run-Time Library for Windows CE doesn't have 146+ * errno. We define it as a global variable to simplify porting. 147+ * Its value is always 0 and should not be used. We rename it to 148+ * avoid conflict with other libraries that use the same workaround. 149+ */ 150+# define errno z_errno 151+# endif 152+ extern int errno; 153+#else 154+# ifndef _WIN32_WCE 155+# include <errno.h> 156+# endif 157+#endif 158 159 #ifdef Z_SOLO 160 typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ 161