Skip to content

Commit

Permalink
deps: update zlib to upstream fc5cfd78a3
Browse files Browse the repository at this point in the history
Updated as described in doc/contributing/maintaining-zlib.md.
  • Loading branch information
targos committed Jan 29, 2022
1 parent ef4c115 commit 6170ee4
Show file tree
Hide file tree
Showing 63 changed files with 3,913 additions and 1,082 deletions.
257 changes: 193 additions & 64 deletions deps/zlib/BUILD.gn

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions deps/zlib/DIR_METADATA
@@ -0,0 +1,3 @@
monorail: {
component: "Internals"
}
6 changes: 2 additions & 4 deletions deps/zlib/OWNERS
@@ -1,7 +1,5 @@
agl@chromium.org
cavalcantii@chromium.org
cblume@chromium.org
mtklein@chromium.org
scroggo@chromium.org

# COMPONENT: Internals
noel@chromium.org
scroggo@google.com
1 change: 1 addition & 0 deletions deps/zlib/README.chromium
Expand Up @@ -2,6 +2,7 @@ Name: zlib
Short Name: zlib
URL: http://zlib.net/
Version: 1.2.11
CPEPrefix: cpe:/a:zlib:zlib:1.2.11
Security Critical: yes
License: Custom license
License File: LICENSE
Expand Down
12 changes: 5 additions & 7 deletions deps/zlib/adler32.c
Expand Up @@ -59,10 +59,8 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
# define MOD63(a) a %= BASE
#endif

#if defined(ADLER32_SIMD_SSSE3)
#include "adler32_simd.h"
#include "x86.h"
#elif defined(ADLER32_SIMD_NEON)
#include "cpu_features.h"
#if defined(ADLER32_SIMD_SSSE3) || defined(ADLER32_SIMD_NEON)
#include "adler32_simd.h"
#endif

Expand All @@ -76,10 +74,10 @@ uLong ZEXPORT adler32_z(adler, buf, len)
unsigned n;

#if defined(ADLER32_SIMD_SSSE3)
if (x86_cpu_enable_ssse3 && buf && len >= 64)
if (buf != Z_NULL && len >= 64 && x86_cpu_enable_ssse3)
return adler32_simd_(adler, buf, len);
#elif defined(ADLER32_SIMD_NEON)
if (buf && len >= 64)
if (buf != Z_NULL && len >= 64)
return adler32_simd_(adler, buf, len);
#endif

Expand Down Expand Up @@ -108,7 +106,7 @@ uLong ZEXPORT adler32_z(adler, buf, len)
*/
if (buf == Z_NULL) {
if (!len) /* Assume user is calling adler32(0, NULL, 0); */
x86_check_features();
cpu_check_features();
return 1L;
}
#else
Expand Down
4 changes: 0 additions & 4 deletions deps/zlib/adler32_simd.c
Expand Up @@ -50,13 +50,9 @@
#define NMAX 5552

#if defined(ADLER32_SIMD_SSSE3)
#ifndef __GNUC__
#define __attribute__()
#endif

#include <tmmintrin.h>

__attribute__((target("ssse3")))
uint32_t ZLIB_INTERNAL adler32_simd_( /* SSSE3 */
uint32_t adler,
const unsigned char *buf,
Expand Down
90 changes: 0 additions & 90 deletions deps/zlib/arm_features.c

This file was deleted.

4 changes: 4 additions & 0 deletions deps/zlib/chromeconf.h
Expand Up @@ -192,4 +192,8 @@
#define arm_check_features Cr_z_arm_check_features
#define armv8_crc32_little Cr_z_armv8_crc32_little

/* Symbols added by cpu_features.c */
#define cpu_check_features Cr_z_cpu_check_features
#define x86_cpu_enable_sse2 Cr_z_x86_cpu_enable_sse2

#endif /* THIRD_PARTY_ZLIB_CHROMECONF_H_ */
83 changes: 62 additions & 21 deletions deps/zlib/contrib/bench/zlib_bench.cc
Expand Up @@ -15,7 +15,7 @@
* Note this code can be compiled outside of the Chromium build system against
* the system zlib (-lz) with g++ or clang++ as follows:
*
* g++|clang++ -O3 -Wall -std=c++11 -lstdc++ -lz zlib_bench.cc
* g++|clang++ -O3 -Wall -std=c++11 zlib_bench.cc -lstdc++ -lz
*/

#include <algorithm>
Expand All @@ -38,7 +38,7 @@ void error_exit(const char* error, int code) {
}

inline char* string_data(std::string* s) {
return s->empty() ? 0 : &*s->begin();
return s->empty() ? nullptr : &*s->begin();
}

struct Data {
Expand Down Expand Up @@ -99,10 +99,25 @@ const char* zlib_wrapper_name(zlib_wrapper type) {
if (type == kWrapperZRAW)
return "RAW";
error_exit("bad wrapper type", int(type));
return 0;
return nullptr;
}

static int zlib_strategy = Z_DEFAULT_STRATEGY;

const char* zlib_level_strategy_name(int compression_level) {
if (compression_level == 0)
return ""; // strategy is meaningless at level 0
if (zlib_strategy == Z_HUFFMAN_ONLY)
return "huffman ";
if (zlib_strategy == Z_RLE)
return "rle ";
if (zlib_strategy == Z_DEFAULT_STRATEGY)
return "";
error_exit("bad strategy", zlib_strategy);
return nullptr;
}

static int zlib_compression_level;
static int zlib_compression_level = Z_DEFAULT_COMPRESSION;

void zlib_compress(
const zlib_wrapper type,
Expand All @@ -119,7 +134,7 @@ void zlib_compress(
memset(&stream, 0, sizeof(stream));

int result = deflateInit2(&stream, zlib_compression_level, Z_DEFLATED,
zlib_stream_wrapper_type(type), MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
zlib_stream_wrapper_type(type), MAX_MEM_LEVEL, zlib_strategy);
if (result != Z_OK)
error_exit("deflateInit2 failed", result);

Expand Down Expand Up @@ -178,14 +193,19 @@ void verify_equal(const char* input, size_t size, std::string* output) {
exit(3);
}

void zlib_file(const char* name, const zlib_wrapper type) {
void zlib_file(const char* name, const zlib_wrapper type, int width) {
/*
* Read the file data.
*/
const auto file = read_file_data_or_exit(name);
const int length = static_cast<int>(file.size);
const char* data = file.data.get();
printf("%-40s :\n", name);

/*
* Report compression strategy and file name.
*/
const char* strategy = zlib_level_strategy_name(zlib_compression_level);
printf("%s%-40s :\n", strategy, name);

/*
* Chop the data into blocks.
Expand Down Expand Up @@ -263,9 +283,9 @@ void zlib_file(const char* name, const zlib_wrapper type) {
double inflate_rate_max = length * repeats / mega_byte / utime[0];

// type, block size, compression ratio, etc
printf("%s: [b %dM] bytes %6d -> %6u %4.1f%%",
zlib_wrapper_name(type), block_size / (1 << 20), length,
static_cast<unsigned>(output_length), output_length * 100.0 / length);
printf("%s: [b %dM] bytes %*d -> %*u %4.2f%%",
zlib_wrapper_name(type), block_size / (1 << 20), width, length, width,
unsigned(output_length), output_length * 100.0 / length);

// compress / uncompress median (max) rates
printf(" comp %5.1f (%5.1f) MB/s uncomp %5.1f (%5.1f) MB/s\n",
Expand All @@ -276,18 +296,24 @@ static int argn = 1;

char* get_option(int argc, char* argv[], const char* option) {
if (argn < argc)
return !strcmp(argv[argn], option) ? argv[argn++] : 0;
return 0;
return !strcmp(argv[argn], option) ? argv[argn++] : nullptr;
return nullptr;
}

bool get_compression(int argc, char* argv[], int* value) {
bool get_compression(int argc, char* argv[], int& value) {
if (argn < argc)
*value = atoi(argv[argn++]);
return *value >= 1 && *value <= 9;
value = isdigit(argv[argn][0]) ? atoi(argv[argn++]) : -1;
return value >= 0 && value <= 9;
}

void get_field_width(int argc, char* argv[], int& value) {
value = atoi(argv[argn++]);
}

void usage_exit(const char* program) {
printf("usage: %s gzip|zlib|raw [--compression 1:9] files...\n", program);
static auto* options =
"gzip|zlib|raw [--compression 0:9] [--huffman|--rle] [--field width]";
printf("usage: %s %s files ...\n", program, options);
exit(1);
}

Expand All @@ -302,15 +328,30 @@ int main(int argc, char* argv[]) {
else
usage_exit(argv[0]);

if (!get_option(argc, argv, "--compression"))
zlib_compression_level = Z_DEFAULT_COMPRESSION;
else if (!get_compression(argc, argv, &zlib_compression_level))
usage_exit(argv[0]);
int file_size_field_width = 0;

while (argn < argc && argv[argn][0] == '-') {
if (get_option(argc, argv, "--compression")) {
if (!get_compression(argc, argv, zlib_compression_level))
usage_exit(argv[0]);
} else if (get_option(argc, argv, "--field")) {
get_field_width(argc, argv, file_size_field_width);
} else if (get_option(argc, argv, "--huffman")) {
zlib_strategy = Z_HUFFMAN_ONLY;
} else if (get_option(argc, argv, "--rle")) {
zlib_strategy = Z_RLE;
} else {
usage_exit(argv[0]);
}
}

if (argn >= argc)
usage_exit(argv[0]);

if (file_size_field_width < 6)
file_size_field_width = 6;
while (argn < argc)
zlib_file(argv[argn++], type);
zlib_file(argv[argn++], type, file_size_field_width);

return 0;
}
8 changes: 3 additions & 5 deletions deps/zlib/contrib/minizip/iowin32.c
Expand Up @@ -31,14 +31,12 @@
#define _WIN32_WINNT 0x601
#endif

#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
// see Include/shared/winapifamily.h in the Windows Kit
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
#if !defined(IOWIN32_USING_WINRT_API)
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
// Windows Store or Universal Windows Platform
#define IOWIN32_USING_WINRT_API 1
#endif
#endif
#endif

voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
Expand Down
13 changes: 6 additions & 7 deletions deps/zlib/contrib/minizip/miniunz.c
Expand Up @@ -12,7 +12,7 @@
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
*/

#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!defined(__ANDROID_API__))
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
Expand All @@ -27,7 +27,7 @@
#endif
#endif

#ifdef __APPLE__
#if defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream)
Expand All @@ -45,6 +45,7 @@
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>

#ifdef _WIN32
# include <direct.h>
Expand Down Expand Up @@ -97,7 +98,7 @@ void change_file_date(filename,dosdate,tmu_date)
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
#else
#ifdef unix || __APPLE__
#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
struct utimbuf ut;
struct tm newdate;
newdate.tm_sec = tmu_date.tm_sec;
Expand Down Expand Up @@ -125,11 +126,9 @@ int mymkdir(dirname)
const char* dirname;
{
int ret=0;
#ifdef _WIN32
#if defined(_WIN32)
ret = _mkdir(dirname);
#elif unix
ret = mkdir (dirname,0775);
#elif __APPLE__
#elif defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
ret = mkdir (dirname,0775);
#endif
return ret;
Expand Down

0 comments on commit 6170ee4

Please sign in to comment.