From e7ca09f310ea017f483876ea7fe9892cadecd4d7 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sat, 18 Mar 2023 21:01:36 +0100 Subject: [PATCH] deps: update zlib to upstream 5edb52d4 Updated as described in doc/contributing/maintaining-zlib.md. Refs: https://github.com/nodejs/node/pull/45387#issuecomment-1462728879 PR-URL: https://github.com/nodejs/node/pull/47151 Reviewed-By: Yagiz Nizipli Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Richard Lau Reviewed-By: Michael Dawson --- deps/zlib/BUILD.gn | 17 +- deps/zlib/CMakeLists.txt | 234 ++++++++ deps/zlib/contrib/optimizations/chunkcopy.h | 2 +- .../contrib/optimizations/inffast_chunk.c | 71 ++- .../contrib/optimizations/inffast_chunk.h | 26 +- .../contrib/optimizations/insert_string.h | 5 +- .../contrib/tests/fuzzers/deflate_fuzzer.cc | 2 +- .../fuzzers/deflate_set_dictionary_fuzzer.cc | 2 +- .../contrib/tests/fuzzers/inflate_fuzzer.cc | 2 +- .../tests/fuzzers/streaming_inflate_fuzzer.cc | 2 +- .../tests/fuzzers/uncompress_fuzzer.cc | 2 +- deps/zlib/contrib/tests/run_all_unittests.cc | 2 +- deps/zlib/google/BUILD.gn | 6 +- deps/zlib/google/OWNERS | 2 - deps/zlib/google/zip.cc | 2 +- deps/zlib/google/zip.h | 2 +- deps/zlib/google/zip_reader.cc | 18 +- deps/zlib/google/zip_reader.h | 2 +- deps/zlib/google/zip_reader_unittest.cc | 2 +- deps/zlib/google/zip_unittest.cc | 2 +- .../zlib/patches/0010-cmake-enable-simd.patch | 96 +++ deps/zlib/zconf.h.cmakein | 549 ++++++++++++++++++ deps/zlib/zlib.3 | 149 +++++ deps/zlib/zlib.gyp | 2 + deps/zlib/zlib.map | 100 ++++ deps/zlib/zlib.pc.cmakein | 13 + 26 files changed, 1252 insertions(+), 60 deletions(-) create mode 100644 deps/zlib/CMakeLists.txt create mode 100644 deps/zlib/patches/0010-cmake-enable-simd.patch create mode 100644 deps/zlib/zconf.h.cmakein create mode 100644 deps/zlib/zlib.3 create mode 100644 deps/zlib/zlib.map create mode 100644 deps/zlib/zlib.pc.cmakein diff --git a/deps/zlib/BUILD.gn b/deps/zlib/BUILD.gn index b85067a12bd86d..5c215860aec16c 100644 --- a/deps/zlib/BUILD.gn +++ b/deps/zlib/BUILD.gn @@ -4,6 +4,12 @@ import("//build/config/compiler/compiler.gni") +declare_args() { + # Expose zlib's symbols, used by Node.js to provide zlib APIs for its native + # modules. + zlib_symbols_visible = false +} + if (build_with_chromium) { import("//testing/test.gni") } @@ -14,6 +20,10 @@ if (current_cpu == "arm" || current_cpu == "arm64") { config("zlib_config") { include_dirs = [ "." ] + + if (zlib_symbols_visible) { + defines = [ "ZLIB_DLL" ] + } } config("zlib_internal_config") { @@ -23,7 +33,7 @@ config("zlib_internal_config") { # Build code using -O3, see: crbug.com/1084371. configs = [ "//build/config/compiler:optimize_speed" ] } - if (is_debug || use_libfuzzer) { + if (is_debug || use_fuzzing_engine) { # Enable zlib's asserts in debug and fuzzer builds. defines += [ "ZLIB_DEBUG" ] } @@ -358,6 +368,11 @@ component("zlib") { configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] + if (zlib_symbols_visible) { + configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] + configs += [ "//build/config/gcc:symbol_visibility_default" ] + } + public_configs = [ ":zlib_config" ] configs += [ diff --git a/deps/zlib/CMakeLists.txt b/deps/zlib/CMakeLists.txt new file mode 100644 index 00000000000000..f06e193f726be7 --- /dev/null +++ b/deps/zlib/CMakeLists.txt @@ -0,0 +1,234 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) + +project(zlib C) + +set(VERSION "1.2.13") + +set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") +set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") +set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") +set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") +set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") + +include(CheckTypeSize) +include(CheckFunctionExists) +include(CheckIncludeFile) +include(CheckCSourceCompiles) +enable_testing() + +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(stdint.h HAVE_STDINT_H) +check_include_file(stddef.h HAVE_STDDEF_H) + +option(ENABLE_SIMD_OPTIMIZATIONS "Enable all SIMD optimizations" OFF) + +# TODO(cavalcantii): add support for other OSes (e.g. Android, fuchsia, osx) +# and architectures (e.g. Arm). +if (ENABLE_SIMD_OPTIMIZATIONS) + add_definitions(-DINFLATE_CHUNK_SIMD_SSE2) + add_definitions(-DADLER32_SIMD_SSSE3) + add_definitions(-DINFLATE_CHUNK_READ_64LE) + add_definitions(-DCRC32_SIMD_SSE42_PCLMUL) + add_definitions(-DDEFLATE_SLIDE_HASH_SSE2) + add_compile_options(-msse4.2 -mpclmul) + # Required by CPU features detection code. + add_definitions(-DX86_NOT_WINDOWS) + # Apparently some environments (e.g. CentOS) require to explicitly link + # with pthread and that is required by the CPU features detection code. + find_package (Threads REQUIRED) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") +endif() + +# +# Check to see if we have large file support +# +set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) +# We add these other definitions here because CheckTypeSize.cmake +# in CMake 2.4.x does not automatically do so and we want +# compatibility with CMake 2.4.x. +if(HAVE_SYS_TYPES_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) +endif() +if(HAVE_STDINT_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) +endif() +if(HAVE_STDDEF_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) +endif() +check_type_size(off64_t OFF64_T) +if(HAVE_OFF64_T) + add_definitions(-D_LARGEFILE64_SOURCE=1) +endif() +set(CMAKE_REQUIRED_DEFINITIONS) # clear variable + +# +# Check for fseeko +# +check_function_exists(fseeko HAVE_FSEEKO) +if(NOT HAVE_FSEEKO) + add_definitions(-DNO_FSEEKO) +endif() + +# +# Check for unistd.h +# +check_include_file(unistd.h Z_HAVE_UNISTD_H) + +if(MSVC) + set(CMAKE_DEBUG_POSTFIX "d") + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +endif() + +if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) + # If we're doing an out of source build and the user has a zconf.h + # in their source tree... + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) + message(STATUS "Renaming") + message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h") + message(STATUS "to 'zconf.h.included' because this file is included with zlib") + message(STATUS "but CMake generates it automatically in the build directory.") + file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included) + endif() +endif() + +set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc) +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein + ${ZLIB_PC} @ONLY) +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein + ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) + + +#============================================================================ +# zlib +#============================================================================ + +set(ZLIB_PUBLIC_HDRS + ${CMAKE_CURRENT_BINARY_DIR}/zconf.h + zlib.h +) +set(ZLIB_PRIVATE_HDRS + crc32.h + deflate.h + gzguts.h + inffast.h + inffixed.h + inflate.h + inftrees.h + trees.h + zutil.h +) +set(ZLIB_SRCS + adler32.c + compress.c + crc32.c + deflate.c + gzclose.c + gzlib.c + gzread.c + gzwrite.c + inflate.c + infback.c + inftrees.c + inffast.c + trees.c + uncompr.c + zutil.c +) + + +#============================================================================ +# Update list of source files if optimizations were enabled +#============================================================================ +if (ENABLE_SIMD_OPTIMIZATIONS) + list(REMOVE_ITEM ZLIB_SRCS inflate.c) + + list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/adler32_simd.h) + list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/chunkcopy.h) + list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/inffast_chunk.h) + list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/cpu_features.h) + list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/crc32_simd.h) + + list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/adler32_simd.c) + list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/inffast_chunk.c) + list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/inflate.c) + list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/cpu_features.c) + list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/crc32_simd.c) + list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/crc_folding.c) +endif() + +# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) +string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" + "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) + +if(MINGW) + # This gets us DLL resource information when compiling on MinGW. + if(NOT CMAKE_RC_COMPILER) + set(CMAKE_RC_COMPILER windres.exe) + endif() + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj + COMMAND ${CMAKE_RC_COMPILER} + -D GCC_WINDRES + -I ${CMAKE_CURRENT_SOURCE_DIR} + -I ${CMAKE_CURRENT_BINARY_DIR} + -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj + -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) + set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) +endif(MINGW) + +add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) +set_target_properties(zlib PROPERTIES SOVERSION 1) + +if(NOT CYGWIN) + # This property causes shared libraries on Linux to have the full version + # encoded into their final filename. We disable this on Cygwin because + # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll + # seems to be the default. + # + # This has no effect with MSVC, on that platform the version info for + # the DLL comes from the resource file win32/zlib1.rc + set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) +endif() + +if(UNIX) + # On unix-like platforms the library is almost always called libz + set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) + if(NOT APPLE) + set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") + endif() +elseif(BUILD_SHARED_LIBS AND WIN32) + # Creates zlib1.dll when building shared library version + set_target_properties(zlib PROPERTIES SUFFIX "1.dll") +endif() + +if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) + install(TARGETS zlib zlibstatic + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" + ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) +endif() +if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) + install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}") +endif() +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3") +endif() +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") +endif() + +#============================================================================ +# Benchmarker +#============================================================================ +enable_language(CXX) +set(CMAKE_CXX_STANDARD 14) # workaround for older compilers (e.g. g++ 5.4). +add_executable(zlib_bench contrib/bench/zlib_bench.cc) +target_link_libraries(zlib_bench zlib) diff --git a/deps/zlib/contrib/optimizations/chunkcopy.h b/deps/zlib/contrib/optimizations/chunkcopy.h index db3c861ba4982a..f40546d54dbe77 100644 --- a/deps/zlib/contrib/optimizations/chunkcopy.h +++ b/deps/zlib/contrib/optimizations/chunkcopy.h @@ -60,7 +60,7 @@ Z_STATIC_ASSERT(vector_128_bits_wide, * instruction appropriate for the z_vec128i_t type. */ static inline z_vec128i_t loadchunk( - const unsigned char FAR* s) { + const unsigned char FAR* s) Z_DISABLE_MSAN { z_vec128i_t v; Z_BUILTIN_MEMCPY(&v, s, sizeof(v)); return v; diff --git a/deps/zlib/contrib/optimizations/inffast_chunk.c b/deps/zlib/contrib/optimizations/inffast_chunk.c index 5b094873aeb97d..a38e14db037496 100644 --- a/deps/zlib/contrib/optimizations/inffast_chunk.c +++ b/deps/zlib/contrib/optimizations/inffast_chunk.c @@ -1,5 +1,6 @@ /* inffast_chunk.c -- fast decoding * Copyright (C) 1995-2017 Mark Adler + * Copyright 2023 The Chromium Authors * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -24,8 +25,8 @@ Entry assumptions: state->mode == LEN - strm->avail_in >= INFLATE_FAST_MIN_INPUT (6 or 8 bytes) - strm->avail_out >= INFLATE_FAST_MIN_OUTPUT (258 bytes) + strm->avail_in >= INFLATE_FAST_MIN_INPUT (6 or 8 bytes + 7 bytes) + strm->avail_out >= INFLATE_FAST_MIN_OUTPUT (258 bytes + 2 bytes) start >= strm->avail_out state->bits < 8 (state->hold >> state->bits) == 0 @@ -42,7 +43,7 @@ Notes: - INFLATE_FAST_MIN_INPUT: 6 or 8 bytes + INFLATE_FAST_MIN_INPUT: 6 or 8 bytes + 7 bytes - The maximum input bits used by a length/distance pair is 15 bits for the length code, 5 bits for the length extra, 15 bits for the distance code, @@ -64,11 +65,11 @@ (state->hold >> state->bits) == 0 - INFLATE_FAST_MIN_OUTPUT: 258 bytes + INFLATE_FAST_MIN_OUTPUT: 258 bytes + 2 bytes for literals = 260 bytes - The maximum bytes that a single length/distance pair can output is 258 bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for + requires strm->avail_out >= 260 for each loop to avoid checking for available output space while decoding. */ void ZLIB_INTERNAL inflate_fast_chunk_(strm, start) @@ -124,22 +125,50 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ lmask = (1U << state->lenbits) - 1; dmask = (1U << state->distbits) - 1; +#ifdef INFLATE_CHUNK_READ_64LE +#define REFILL() do { \ + Assert(bits < 64, "### Too many bits in inflate_fast."); \ + hold |= read64le(in) << bits; \ + in += 7; \ + in -= bits >> 3; \ + bits |= 56; \ + } while (0) +#endif + /* decode literals and length/distances until end-of-block or not enough input data or output space */ do { - if (bits < 15) { #ifdef INFLATE_CHUNK_READ_64LE - hold |= read64le(in) << bits; - in += 6; - bits += 48; + REFILL(); #else + if (bits < 15) { hold += (unsigned long)(*in++) << bits; bits += 8; hold += (unsigned long)(*in++) << bits; bits += 8; -#endif } +#endif here = lcode + (hold & lmask); +#ifdef INFLATE_CHUNK_READ_64LE + if (here->op == 0) { /* literal */ + Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", here->val)); + *out++ = (unsigned char)(here->val); + hold >>= here->bits; + bits -= here->bits; + here = lcode + (hold & lmask); + if (here->op == 0) { /* literal */ + Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ? + "inflate: 2nd literal '%c'\n" : + "inflate: 2nd literal 0x%02x\n", here->val)); + *out++ = (unsigned char)(here->val); + hold >>= here->bits; + bits -= here->bits; + here = lcode + (hold & lmask); + } + } +#endif dolen: op = (unsigned)(here->bits); hold >>= op; @@ -155,33 +184,25 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ len = (unsigned)(here->val); op &= 15; /* number of extra bits */ if (op) { +#ifndef INFLATE_CHUNK_READ_64LE if (bits < op) { -#ifdef INFLATE_CHUNK_READ_64LE - hold |= read64le(in) << bits; - in += 6; - bits += 48; -#else hold += (unsigned long)(*in++) << bits; bits += 8; -#endif } +#endif len += (unsigned)hold & ((1U << op) - 1); hold >>= op; bits -= op; } Tracevv((stderr, "inflate: length %u\n", len)); +#ifndef INFLATE_CHUNK_READ_64LE if (bits < 15) { -#ifdef INFLATE_CHUNK_READ_64LE - hold |= read64le(in) << bits; - in += 6; - bits += 48; -#else hold += (unsigned long)(*in++) << bits; bits += 8; hold += (unsigned long)(*in++) << bits; bits += 8; -#endif } +#endif here = dcode + (hold & dmask); dodist: op = (unsigned)(here->bits); @@ -191,11 +212,11 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ if (op & 16) { /* distance base */ dist = (unsigned)(here->val); op &= 15; /* number of extra bits */ + /* we have two fast-path loads: 10+10 + 15+5 + 15 = 55, + but we may need to refill here in the worst case */ if (bits < op) { #ifdef INFLATE_CHUNK_READ_64LE - hold |= read64le(in) << bits; - in += 6; - bits += 48; + REFILL(); #else hold += (unsigned long)(*in++) << bits; bits += 8; diff --git a/deps/zlib/contrib/optimizations/inffast_chunk.h b/deps/zlib/contrib/optimizations/inffast_chunk.h index 39c771b863c7ed..cc861bd09d1240 100644 --- a/deps/zlib/contrib/optimizations/inffast_chunk.h +++ b/deps/zlib/contrib/optimizations/inffast_chunk.h @@ -1,6 +1,7 @@ /* inffast_chunk.h -- header to use inffast_chunk.c * Copyright (C) 1995-2003, 2010 Mark Adler * Copyright (C) 2017 ARM, Inc. + * Copyright 2023 The Chromium Authors * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -11,16 +12,31 @@ #include "inffast.h" -/* INFLATE_FAST_MIN_INPUT: the minimum number of input bytes needed so that - we can safely call inflate_fast() with only one up-front bounds check. One +/* INFLATE_FAST_MIN_INPUT: + The minimum number of input bytes needed so that we can safely call + inflate_fast() with only one up-front bounds check. One length/distance code pair (15 bits for the length code, 5 bits for length extra, 15 bits for the distance code, 13 bits for distance extra) requires - reading up to 48 input bits (6 bytes). The wide input data reading option - requires a little endian machine, and reads 64 input bits (8 bytes). + reading up to 48 input bits. Additionally, in the same iteraction, we may + decode two literals from the root-table (requiring MIN_OUTPUT = 258 + 2). + + Each root-table entry is up to 10 bits, for a total of 68 input bits each + iteraction. + + The refill variant reads 8 bytes from the buffer at a time, and advances + the input pointer by up to 7 bytes, ensuring there are at least 56-bits + available in the bit-buffer. The technique was documented by Fabian Giesen + on his blog as variant 4 in the article 'Reading bits in far too many ways': + https://fgiesen.wordpress.com/2018/02/20/ + + In the worst case, we may refill twice in the same iteraction, requiring + MIN_INPUT = 8 + 7. */ #ifdef INFLATE_CHUNK_READ_64LE #undef INFLATE_FAST_MIN_INPUT -#define INFLATE_FAST_MIN_INPUT 8 +#define INFLATE_FAST_MIN_INPUT 15 +#undef INFLATE_FAST_MIN_OUTPUT +#define INFLATE_FAST_MIN_OUTPUT 260 #endif void ZLIB_INTERNAL inflate_fast_chunk_ OF((z_streamp strm, unsigned start)); diff --git a/deps/zlib/contrib/optimizations/insert_string.h b/deps/zlib/contrib/optimizations/insert_string.h index 2a04f699349435..c6a296aef7390e 100644 --- a/deps/zlib/contrib/optimizations/insert_string.h +++ b/deps/zlib/contrib/optimizations/insert_string.h @@ -57,10 +57,9 @@ TARGET_CPU_WITH_CRC local INLINE Pos insert_string_simd(deflate_state* const s, const Pos str) { Pos ret; - unsigned *ip, val, h = 0; + unsigned val, h = 0; - ip = (unsigned*)&s->window[str]; - val = *ip; + zmemcpy(&val, &s->window[str], sizeof(val)); if (s->level >= 6) val &= 0xFFFFFF; diff --git a/deps/zlib/contrib/tests/fuzzers/deflate_fuzzer.cc b/deps/zlib/contrib/tests/fuzzers/deflate_fuzzer.cc index cf1a9649591225..ad1a985c68334a 100644 --- a/deps/zlib/contrib/tests/fuzzers/deflate_fuzzer.cc +++ b/deps/zlib/contrib/tests/fuzzers/deflate_fuzzer.cc @@ -10,7 +10,7 @@ #include #include -#include "third_party/zlib/zlib.h" +#include "zlib.h" // Fuzzer builds often have NDEBUG set, so roll our own assert macro. #define ASSERT(cond) \ diff --git a/deps/zlib/contrib/tests/fuzzers/deflate_set_dictionary_fuzzer.cc b/deps/zlib/contrib/tests/fuzzers/deflate_set_dictionary_fuzzer.cc index 88511c14fe5ec9..96778209f7f91c 100644 --- a/deps/zlib/contrib/tests/fuzzers/deflate_set_dictionary_fuzzer.cc +++ b/deps/zlib/contrib/tests/fuzzers/deflate_set_dictionary_fuzzer.cc @@ -7,7 +7,7 @@ #include #include -#include "third_party/zlib/zlib.h" +#include "zlib.h" static Bytef buffer[256 * 1024] = {0}; diff --git a/deps/zlib/contrib/tests/fuzzers/inflate_fuzzer.cc b/deps/zlib/contrib/tests/fuzzers/inflate_fuzzer.cc index 836a4415fa7517..d9d62026e42956 100644 --- a/deps/zlib/contrib/tests/fuzzers/inflate_fuzzer.cc +++ b/deps/zlib/contrib/tests/fuzzers/inflate_fuzzer.cc @@ -8,7 +8,7 @@ #include #include -#include "third_party/zlib/zlib.h" +#include "zlib.h" static Bytef buffer[256 * 1024] = {0}; diff --git a/deps/zlib/contrib/tests/fuzzers/streaming_inflate_fuzzer.cc b/deps/zlib/contrib/tests/fuzzers/streaming_inflate_fuzzer.cc index c054e984b807ce..dac170a0fc541e 100644 --- a/deps/zlib/contrib/tests/fuzzers/streaming_inflate_fuzzer.cc +++ b/deps/zlib/contrib/tests/fuzzers/streaming_inflate_fuzzer.cc @@ -7,7 +7,7 @@ #include #include -#include "third_party/zlib/zlib.h" +#include "zlib.h" // Fuzzer builds often have NDEBUG set, so roll our own assert macro. #define ASSERT(cond) \ diff --git a/deps/zlib/contrib/tests/fuzzers/uncompress_fuzzer.cc b/deps/zlib/contrib/tests/fuzzers/uncompress_fuzzer.cc index c41747a144c059..e63a8c0582dfc1 100644 --- a/deps/zlib/contrib/tests/fuzzers/uncompress_fuzzer.cc +++ b/deps/zlib/contrib/tests/fuzzers/uncompress_fuzzer.cc @@ -6,7 +6,7 @@ #include #include -#include "third_party/zlib/zlib.h" +#include "zlib.h" static Bytef buffer[256 * 1024] = {0}; diff --git a/deps/zlib/contrib/tests/run_all_unittests.cc b/deps/zlib/contrib/tests/run_all_unittests.cc index af2ef5dfaa445d..4b6115b074f7f7 100644 --- a/deps/zlib/contrib/tests/run_all_unittests.cc +++ b/deps/zlib/contrib/tests/run_all_unittests.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/bind.h" +#include "base/functional/bind.h" #include "base/test/launcher/unit_test_launcher.h" #include "base/test/test_suite.h" diff --git a/deps/zlib/google/BUILD.gn b/deps/zlib/google/BUILD.gn index 35ba1daf2dfea3..990b0232306bdb 100644 --- a/deps/zlib/google/BUILD.gn +++ b/deps/zlib/google/BUILD.gn @@ -18,9 +18,9 @@ if (build_with_chromium) { "zip_writer.h", ] deps = [ + "..:minizip", "//base", "//base:i18n", - "//third_party/zlib:minizip", ] } @@ -30,8 +30,8 @@ if (build_with_chromium) { "compression_utils.h", ] deps = [ + "..", "//base", - "//third_party/zlib", ] public_deps = [ ":compression_utils_portable" ] } @@ -44,5 +44,5 @@ static_library("compression_utils_portable") { "compression_utils_portable.cc", "compression_utils_portable.h", ] - public_deps = [ "//third_party/zlib" ] + public_deps = [ ".." ] } diff --git a/deps/zlib/google/OWNERS b/deps/zlib/google/OWNERS index 411670ca13aa17..868af3cc662852 100644 --- a/deps/zlib/google/OWNERS +++ b/deps/zlib/google/OWNERS @@ -1,5 +1,3 @@ -fdegros@chromium.org -noel@chromium.org satorux@chromium.org # compression_utils* diff --git a/deps/zlib/google/zip.cc b/deps/zlib/google/zip.cc index 490dcee34e1e42..87065b9188785a 100644 --- a/deps/zlib/google/zip.cc +++ b/deps/zlib/google/zip.cc @@ -7,10 +7,10 @@ #include #include -#include "base/bind.h" #include "base/files/file.h" #include "base/files/file_enumerator.h" #include "base/files/file_util.h" +#include "base/functional/bind.h" #include "base/logging.h" #include "base/memory/ptr_util.h" #include "base/strings/string_util.h" diff --git a/deps/zlib/google/zip.h b/deps/zlib/google/zip.h index e3036c809c2376..ea8778681da00a 100644 --- a/deps/zlib/google/zip.h +++ b/deps/zlib/google/zip.h @@ -10,10 +10,10 @@ #include #include -#include "base/callback.h" #include "base/containers/span.h" #include "base/files/file_path.h" #include "base/files/platform_file.h" +#include "base/functional/callback.h" #include "base/time/time.h" #include "build/build_config.h" diff --git a/deps/zlib/google/zip_reader.cc b/deps/zlib/google/zip_reader.cc index e97027a0bbb2fb..9b1030a029c8a4 100644 --- a/deps/zlib/google/zip_reader.cc +++ b/deps/zlib/google/zip_reader.cc @@ -7,10 +7,10 @@ #include #include -#include "base/bind.h" #include "base/check.h" #include "base/files/file.h" #include "base/files/file_util.h" +#include "base/functional/bind.h" #include "base/i18n/icu_string_conversions.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" @@ -18,7 +18,7 @@ #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "base/threading/sequenced_task_runner_handle.h" +#include "base/task/sequenced_task_runner.h" #include "build/build_config.h" #include "third_party/zlib/google/redact.h" #include "third_party/zlib/google/zip_internal.h" @@ -461,11 +461,11 @@ void ZipReader::ExtractCurrentEntryToFilePathAsync( // If this is a directory, just create it and return. if (entry_.is_directory) { if (base::CreateDirectory(output_file_path)) { - base::SequencedTaskRunnerHandle::Get()->PostTask( + base::SequencedTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, std::move(success_callback)); } else { LOG(ERROR) << "Cannot create directory " << Redact(output_file_path); - base::SequencedTaskRunnerHandle::Get()->PostTask( + base::SequencedTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, std::move(failure_callback)); } return; @@ -479,7 +479,7 @@ void ZipReader::ExtractCurrentEntryToFilePathAsync( err != UNZ_OK) { LOG(ERROR) << "Cannot open file " << Redact(entry_.path) << " from ZIP: " << err; - base::SequencedTaskRunnerHandle::Get()->PostTask( + base::SequencedTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, std::move(failure_callback)); return; } @@ -487,7 +487,7 @@ void ZipReader::ExtractCurrentEntryToFilePathAsync( base::FilePath output_dir_path = output_file_path.DirName(); if (!base::CreateDirectory(output_dir_path)) { LOG(ERROR) << "Cannot create directory " << Redact(output_dir_path); - base::SequencedTaskRunnerHandle::Get()->PostTask( + base::SequencedTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, std::move(failure_callback)); return; } @@ -497,12 +497,12 @@ void ZipReader::ExtractCurrentEntryToFilePathAsync( if (!output_file.IsValid()) { LOG(ERROR) << "Cannot create file " << Redact(output_file_path); - base::SequencedTaskRunnerHandle::Get()->PostTask( + base::SequencedTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, std::move(failure_callback)); return; } - base::SequencedTaskRunnerHandle::Get()->PostTask( + base::SequencedTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, base::BindOnce(&ZipReader::ExtractChunk, weak_ptr_factory_.GetWeakPtr(), std::move(output_file), std::move(success_callback), @@ -602,7 +602,7 @@ void ZipReader::ExtractChunk(base::File output_file, offset += num_bytes_read; progress_callback.Run(offset); - base::SequencedTaskRunnerHandle::Get()->PostTask( + base::SequencedTaskRunner::GetCurrentDefault()->PostTask( FROM_HERE, base::BindOnce(&ZipReader::ExtractChunk, weak_ptr_factory_.GetWeakPtr(), std::move(output_file), std::move(success_callback), diff --git a/deps/zlib/google/zip_reader.h b/deps/zlib/google/zip_reader.h index 48244c8238368e..b7680cc839386a 100644 --- a/deps/zlib/google/zip_reader.h +++ b/deps/zlib/google/zip_reader.h @@ -11,9 +11,9 @@ #include #include -#include "base/callback.h" #include "base/files/file.h" #include "base/files/file_path.h" +#include "base/functional/callback.h" #include "base/memory/weak_ptr.h" #include "base/numerics/safe_conversions.h" #include "base/time/time.h" diff --git a/deps/zlib/google/zip_reader_unittest.cc b/deps/zlib/google/zip_reader_unittest.cc index 52dab200a3494c..b9175045d07268 100644 --- a/deps/zlib/google/zip_reader_unittest.cc +++ b/deps/zlib/google/zip_reader_unittest.cc @@ -12,12 +12,12 @@ #include #include -#include "base/bind.h" #include "base/check.h" #include "base/files/file.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" +#include "base/functional/bind.h" #include "base/hash/md5.h" #include "base/path_service.h" #include "base/run_loop.h" diff --git a/deps/zlib/google/zip_unittest.cc b/deps/zlib/google/zip_unittest.cc index b639e8e8437799..24ed147729f720 100644 --- a/deps/zlib/google/zip_unittest.cc +++ b/deps/zlib/google/zip_unittest.cc @@ -12,12 +12,12 @@ #include #include -#include "base/bind.h" #include "base/files/file.h" #include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" +#include "base/functional/bind.h" #include "base/logging.h" #include "base/path_service.h" #include "base/strings/strcat.h" diff --git a/deps/zlib/patches/0010-cmake-enable-simd.patch b/deps/zlib/patches/0010-cmake-enable-simd.patch new file mode 100644 index 00000000000000..3893101b7c6a7e --- /dev/null +++ b/deps/zlib/patches/0010-cmake-enable-simd.patch @@ -0,0 +1,96 @@ +diff --git a/third_party/zlib/CMakeLists.txt b/third_party/zlib/CMakeLists.txt +index b412dc7feb732..0431278405046 100644 +--- a/third_party/zlib/CMakeLists.txt ++++ b/third_party/zlib/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 2.4.4) ++cmake_minimum_required(VERSION 3.0) + set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) + + project(zlib C) +@@ -21,6 +21,26 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H) + check_include_file(stdint.h HAVE_STDINT_H) + check_include_file(stddef.h HAVE_STDDEF_H) + ++option(ENABLE_SIMD_OPTIMIZATIONS "Enable all SIMD optimizations" OFF) ++ ++# TODO(cavalcantii): add support for other OSes (e.g. Android, fuchsia, osx) ++# and architectures (e.g. Arm). ++if (ENABLE_SIMD_OPTIMIZATIONS) ++ add_definitions(-DINFLATE_CHUNK_SIMD_SSE2) ++ add_definitions(-DADLER32_SIMD_SSSE3) ++ add_definitions(-DINFLATE_CHUNK_READ_64LE) ++ add_definitions(-DCRC32_SIMD_SSE42_PCLMUL) ++ add_definitions(-DDEFLATE_SLIDE_HASH_SSE2) ++ add_compile_options(-msse4.2 -mpclmul) ++ # Required by CPU features detection code. ++ add_definitions(-DX86_NOT_WINDOWS) ++ # Apparently some environments (e.g. CentOS) require to explicitly link ++ # with pthread and that is required by the CPU features detection code. ++ find_package (Threads REQUIRED) ++ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") ++ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") ++endif() ++ + # + # Check to see if we have large file support + # +@@ -120,10 +140,25 @@ set(ZLIB_SRCS + zutil.c + ) + +-if(NOT MINGW) +- set(ZLIB_DLL_SRCS +- win32/zlib1.rc # If present will override custom build rule below. +- ) ++ ++#============================================================================ ++# Update list of source files if optimizations were enabled ++#============================================================================ ++if (ENABLE_SIMD_OPTIMIZATIONS) ++ list(REMOVE_ITEM ZLIB_SRCS inflate.c) ++ ++ list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/adler32_simd.h) ++ list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/chunkcopy.h) ++ list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/inffast_chunk.h) ++ list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/cpu_features.h) ++ list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/crc32_simd.h) ++ ++ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/adler32_simd.c) ++ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/inffast_chunk.c) ++ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/inflate.c) ++ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/cpu_features.c) ++ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/crc32_simd.c) ++ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/crc_folding.c) + endif() + + # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION +@@ -191,23 +226,9 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + endif() + + #============================================================================ +-# Example binaries ++# Benchmarker + #============================================================================ +- +-add_executable(example test/example.c) +-target_link_libraries(example zlib) +-add_test(example example) +- +-add_executable(minigzip test/minigzip.c) +-target_link_libraries(minigzip zlib) +- +-if(HAVE_OFF64_T) +- add_executable(example64 test/example.c) +- target_link_libraries(example64 zlib) +- set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") +- add_test(example64 example64) +- +- add_executable(minigzip64 test/minigzip.c) +- target_link_libraries(minigzip64 zlib) +- set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") +-endif() ++enable_language(CXX) ++set(CMAKE_CXX_STANDARD 14) # workaround for older compilers (e.g. g++ 5.4). ++add_executable(zlib_bench contrib/bench/zlib_bench.cc) ++target_link_libraries(zlib_bench zlib) diff --git a/deps/zlib/zconf.h.cmakein b/deps/zlib/zconf.h.cmakein new file mode 100644 index 00000000000000..247ba2461dd09e --- /dev/null +++ b/deps/zlib/zconf.h.cmakein @@ -0,0 +1,549 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H +#cmakedefine Z_PREFIX +#cmakedefine Z_HAVE_UNISTD_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. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ +# define Z_PREFIX_SET + +/* all linked symbols and init macros */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_bits z__tr_flush_bits +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define adler32_z z_adler32_z +# ifndef Z_SOLO +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# endif +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define crc32_combine_gen z_crc32_combine_gen +# define crc32_combine_gen64 z_crc32_combine_gen64 +# define crc32_combine_op z_crc32_combine_op +# define crc32_z z_crc32_z +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateGetDictionary z_deflateGetDictionary +# define deflateInit z_deflateInit +# define deflateInit2 z_deflateInit2 +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePending z_deflatePending +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateResetKeep z_deflateResetKeep +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# ifndef Z_SOLO +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzfread z_gzfread +# define gzfwrite z_gzfwrite +# define gzgetc z_gzgetc +# define gzgetc_ z_gzgetc_ +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# ifdef _WIN32 +# define gzopen_w z_gzopen_w +# endif +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzvprintf z_gzvprintf +# define gzwrite z_gzwrite +# endif +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit z_inflateBackInit +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCodesUsed z_inflateCodesUsed +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetDictionary z_inflateGetDictionary +# define inflateGetHeader z_inflateGetHeader +# define inflateInit z_inflateInit +# define inflateInit2 z_inflateInit2 +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateResetKeep z_inflateResetKeep +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflateValidate z_inflateValidate +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# ifndef Z_SOLO +# define uncompress z_uncompress +# define uncompress2 z_uncompress2 +# endif +# define zError z_zError +# ifndef Z_SOLO +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# endif +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# ifndef Z_SOLO +# define gzFile z_gzFile +# endif +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +#if defined(ZLIB_CONST) && !defined(z_const) +# define z_const const +#else +# define z_const +#endif + +#ifdef Z_SOLO + typedef unsigned long z_size_t; +#else +# define z_longlong long long +# if defined(NO_SIZE_T) + typedef unsigned NO_SIZE_T z_size_t; +# elif defined(STDC) +# include + typedef size_t z_size_t; +# else + typedef unsigned long z_size_t; +# endif +# undef z_longlong +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus about 7 kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +#ifndef Z_ARG /* function prototypes for stdarg */ +# if defined(STDC) || defined(Z_HAVE_STDARG_H) +# define Z_ARG(args) args +# else +# define Z_ARG(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) +# include +# if (UINT_MAX == 0xffffffffUL) +# define Z_U4 unsigned +# elif (ULONG_MAX == 0xffffffffUL) +# define Z_U4 unsigned long +# elif (USHRT_MAX == 0xffffffffUL) +# define Z_U4 unsigned short +# endif +#endif + +#ifdef Z_U4 + typedef Z_U4 z_crc_t; +#else + typedef unsigned long z_crc_t; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_STDARG_H +#endif + +#ifdef STDC +# ifndef Z_SOLO +# include /* for off_t */ +# endif +#endif + +#if defined(STDC) || defined(Z_HAVE_STDARG_H) +# ifndef Z_SOLO +# include /* for va_list */ +# endif +#endif + +#ifdef _WIN32 +# ifndef Z_SOLO +# include /* for wchar_t */ +# endif +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#ifndef Z_HAVE_UNISTD_H +# ifdef __WATCOMC__ +# define Z_HAVE_UNISTD_H +# endif +#endif +#ifndef Z_HAVE_UNISTD_H +# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32) +# define Z_HAVE_UNISTD_H +# endif +#endif +#ifndef Z_SOLO +# if defined(Z_HAVE_UNISTD_H) +# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +# endif +#endif + +#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 +# define Z_LFS64 +#endif + +#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) +# define Z_LARGE64 +#endif + +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) +# define Z_WANT64 +#endif + +#if !defined(SEEK_SET) && !defined(Z_SOLO) +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if !defined(_WIN32) && defined(Z_LARGE64) +# define z_off64_t off64_t +#else +# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# define z_off64_t __int64 +# else +# define z_off64_t z_off_t +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/deps/zlib/zlib.3 b/deps/zlib/zlib.3 new file mode 100644 index 00000000000000..6f6e91404dff19 --- /dev/null +++ b/deps/zlib/zlib.3 @@ -0,0 +1,149 @@ +.TH ZLIB 3 "13 Oct 2022" +.SH NAME +zlib \- compression/decompression library +.SH SYNOPSIS +[see +.I zlib.h +for full description] +.SH DESCRIPTION +The +.I zlib +library is a general purpose data compression library. +The code is thread safe, assuming that the standard library functions +used are thread safe, such as memory allocation routines. +It provides in-memory compression and decompression functions, +including integrity checks of the uncompressed data. +This version of the library supports only one compression method (deflation) +but other algorithms may be added later +with the same stream interface. +.LP +Compression can be done in a single step if the buffers are large enough +or can be done by repeated calls of the compression function. +In the latter case, +the application must provide more input and/or consume the output +(providing more output space) before each call. +.LP +The library also supports reading and writing files in +.IR gzip (1) +(.gz) format +with an interface similar to that of stdio. +.LP +The library does not install any signal handler. +The decoder checks the consistency of the compressed data, +so the library should never crash even in the case of corrupted input. +.LP +All functions of the compression library are documented in the file +.IR zlib.h . +The distribution source includes examples of use of the library +in the files +.I test/example.c +and +.IR test/minigzip.c, +as well as other examples in the +.IR examples/ +directory. +.LP +Changes to this version are documented in the file +.I ChangeLog +that accompanies the source. +.LP +.I zlib +is built in to many languages and operating systems, including but not limited to +Java, Python, .NET, PHP, Perl, Ruby, Swift, and Go. +.LP +An experimental package to read and write files in the .zip format, +written on top of +.I zlib +by Gilles Vollant (info@winimage.com), +is available at: +.IP +http://www.winimage.com/zLibDll/minizip.html +and also in the +.I contrib/minizip +directory of the main +.I zlib +source distribution. +.SH "SEE ALSO" +The +.I zlib +web site can be found at: +.IP +http://zlib.net/ +.LP +The data format used by the +.I zlib +library is described by RFC +(Request for Comments) 1950 to 1952 in the files: +.IP +http://tools.ietf.org/html/rfc1950 (for the zlib header and trailer format) +.br +http://tools.ietf.org/html/rfc1951 (for the deflate compressed data format) +.br +http://tools.ietf.org/html/rfc1952 (for the gzip header and trailer format) +.LP +Mark Nelson wrote an article about +.I zlib +for the Jan. 1997 issue of Dr. Dobb's Journal; +a copy of the article is available at: +.IP +http://marknelson.us/1997/01/01/zlib-engine/ +.SH "REPORTING PROBLEMS" +Before reporting a problem, +please check the +.I zlib +web site to verify that you have the latest version of +.IR zlib ; +otherwise, +obtain the latest version and see if the problem still exists. +Please read the +.I zlib +FAQ at: +.IP +http://zlib.net/zlib_faq.html +.LP +before asking for help. +Send questions and/or comments to zlib@gzip.org, +or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). +.SH AUTHORS AND LICENSE +Version 1.2.13 +.LP +Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler +.LP +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. +.LP +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: +.LP +.nr step 1 1 +.IP \n[step]. 3 +The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software +in a product, an acknowledgment in the product documentation would be +appreciated but is not required. +.IP \n+[step]. +Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. +.IP \n+[step]. +This notice may not be removed or altered from any source distribution. +.LP +Jean-loup Gailly Mark Adler +.br +jloup@gzip.org madler@alumni.caltech.edu +.LP +The deflate format used by +.I zlib +was defined by Phil Katz. +The deflate and +.I zlib +specifications were written by L. Peter Deutsch. +Thanks to all the people who reported problems and suggested various +improvements in +.IR zlib ; +who are too numerous to cite here. +.LP +UNIX manual page by R. P. C. Rodgers, +U.S. National Library of Medicine (rodgers@nlm.nih.gov). +.\" end of man page diff --git a/deps/zlib/zlib.gyp b/deps/zlib/zlib.gyp index c57918cc4613f6..49de2a6c6de903 100644 --- a/deps/zlib/zlib.gyp +++ b/deps/zlib/zlib.gyp @@ -186,6 +186,8 @@ 'cflags!': [ '-ansi' ], 'cflags': [ '-Wno-implicit-fallthrough' ], 'defines': [ 'HAVE_HIDDEN' ], + }, { + 'defines': [ 'ZLIB_DLL' ] }], ['OS=="mac" or OS=="ios" or OS=="freebsd" or OS=="android"', { # Mac, Android and the BSDs don't have fopen64, ftello64, or diff --git a/deps/zlib/zlib.map b/deps/zlib/zlib.map new file mode 100644 index 00000000000000..b330b606febbea --- /dev/null +++ b/deps/zlib/zlib.map @@ -0,0 +1,100 @@ +ZLIB_1.2.0 { + global: + compressBound; + deflateBound; + inflateBack; + inflateBackEnd; + inflateBackInit_; + inflateCopy; + local: + deflate_copyright; + inflate_copyright; + inflate_fast; + inflate_table; + zcalloc; + zcfree; + z_errmsg; + gz_error; + gz_intmax; + _*; +}; + +ZLIB_1.2.0.2 { + gzclearerr; + gzungetc; + zlibCompileFlags; +} ZLIB_1.2.0; + +ZLIB_1.2.0.8 { + deflatePrime; +} ZLIB_1.2.0.2; + +ZLIB_1.2.2 { + adler32_combine; + crc32_combine; + deflateSetHeader; + inflateGetHeader; +} ZLIB_1.2.0.8; + +ZLIB_1.2.2.3 { + deflateTune; + gzdirect; +} ZLIB_1.2.2; + +ZLIB_1.2.2.4 { + inflatePrime; +} ZLIB_1.2.2.3; + +ZLIB_1.2.3.3 { + adler32_combine64; + crc32_combine64; + gzopen64; + gzseek64; + gztell64; + inflateUndermine; +} ZLIB_1.2.2.4; + +ZLIB_1.2.3.4 { + inflateReset2; + inflateMark; +} ZLIB_1.2.3.3; + +ZLIB_1.2.3.5 { + gzbuffer; + gzoffset; + gzoffset64; + gzclose_r; + gzclose_w; +} ZLIB_1.2.3.4; + +ZLIB_1.2.5.1 { + deflatePending; +} ZLIB_1.2.3.5; + +ZLIB_1.2.5.2 { + deflateResetKeep; + gzgetc_; + inflateResetKeep; +} ZLIB_1.2.5.1; + +ZLIB_1.2.7.1 { + inflateGetDictionary; + gzvprintf; +} ZLIB_1.2.5.2; + +ZLIB_1.2.9 { + inflateCodesUsed; + inflateValidate; + uncompress2; + gzfread; + gzfwrite; + deflateGetDictionary; + adler32_z; + crc32_z; +} ZLIB_1.2.7.1; + +ZLIB_1.2.12 { + crc32_combine_gen; + crc32_combine_gen64; + crc32_combine_op; +} ZLIB_1.2.9; diff --git a/deps/zlib/zlib.pc.cmakein b/deps/zlib/zlib.pc.cmakein new file mode 100644 index 00000000000000..a5e642938c6985 --- /dev/null +++ b/deps/zlib/zlib.pc.cmakein @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@INSTALL_LIB_DIR@ +sharedlibdir=@INSTALL_LIB_DIR@ +includedir=@INSTALL_INC_DIR@ + +Name: zlib +Description: zlib compression library +Version: @VERSION@ + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -lz +Cflags: -I${includedir}