| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -124,45 +124,40 @@ source_set("zlib_adler32_simd") { | |||
| 124 | 124 | ||
| 125 | 125 | if (use_arm_neon_optimizations) { | |
| 126 | 126 | config("zlib_arm_crc32_config") { | |
| 127 | - # Disabled for iPhone, as described in DDI0487C_a_armv8_arm: | ||
| 128 | - # "All implementations of the ARMv8.1 architecture are required to | ||
| 129 | - # implement the CRC32* instructions. These are optional in ARMv8.0." | ||
| 130 | - if (!is_ios) { | ||
| 131 | - defines = [ "CRC32_ARMV8_CRC32" ] | ||
| 132 | - if (is_android) { | ||
| 133 | - defines += [ "ARMV8_OS_ANDROID" ] | ||
| 134 | - } else if (is_linux || is_chromeos) { | ||
| 135 | - defines += [ "ARMV8_OS_LINUX" ] | ||
| 136 | - } else if (is_mac) { | ||
| 137 | - defines += [ "ARMV8_OS_MACOS" ] | ||
| 138 | - } else if (is_fuchsia) { | ||
| 139 | - defines += [ "ARMV8_OS_FUCHSIA" ] | ||
| 140 | - } else if (is_win) { | ||
| 141 | - defines += [ "ARMV8_OS_WINDOWS" ] | ||
| 142 | - } else { | ||
| 143 | - assert(false, "Unsupported ARM OS") | ||
| 144 | - } | ||
| 127 | + defines = [ "CRC32_ARMV8_CRC32" ] | ||
| 128 | + if (is_android) { | ||
| 129 | + defines += [ "ARMV8_OS_ANDROID" ] | ||
| 130 | + } else if (is_linux || is_chromeos) { | ||
| 131 | + defines += [ "ARMV8_OS_LINUX" ] | ||
| 132 | + } else if (is_mac) { | ||
| 133 | + defines += [ "ARMV8_OS_MACOS" ] | ||
| 134 | + } else if (is_ios) { | ||
| 135 | + defines += [ "ARMV8_OS_IOS" ] | ||
| 136 | + } else if (is_fuchsia) { | ||
| 137 | + defines += [ "ARMV8_OS_FUCHSIA" ] | ||
| 138 | + } else if (is_win) { | ||
| 139 | + defines += [ "ARMV8_OS_WINDOWS" ] | ||
| 140 | + } else { | ||
| 141 | + assert(false, "Unsupported ARM OS") | ||
| 145 | 142 | } | |
| 146 | 143 | } | |
| 147 | 144 | ||
| 148 | 145 | source_set("zlib_arm_crc32") { | |
| 149 | 146 | visibility = [ ":*" ] | |
| 150 | 147 | ||
| 151 | - if (!is_ios) { | ||
| 152 | - include_dirs = [ "." ] | ||
| 153 | - | ||
| 154 | - if (!is_win && !is_clang) { | ||
| 155 | - assert(!use_thin_lto, | ||
| 156 | - "ThinLTO fails mixing different module-level targets") | ||
| 157 | - cflags_c = [ "-march=armv8-a+aes+crc" ] | ||
| 158 | - } | ||
| 148 | + include_dirs = [ "." ] | ||
| 159 | 149 | ||
| 160 | - sources = [ | ||
| 161 | - "crc32_simd.c", | ||
| 162 | - "crc32_simd.h", | ||
| 163 | - ] | ||
| 150 | + if (!is_win && !is_clang) { | ||
| 151 | + assert(!use_thin_lto, | ||
| 152 | + "ThinLTO fails mixing different module-level targets") | ||
| 153 | + cflags_c = [ "-march=armv8-a+aes+crc" ] | ||
| 164 | 154 | } | |
| 165 | 155 | ||
| 156 | + sources = [ | ||
| 157 | + "crc32_simd.c", | ||
| 158 | + "crc32_simd.h", | ||
| 159 | + ] | ||
| 160 | + | ||
| 166 | 161 | configs += [ ":zlib_internal_config" ] | |
| 167 | 162 | ||
| 168 | 163 | public_configs = [ ":zlib_arm_crc32_config" ] | |
@@ -332,14 +327,6 @@ component("zlib") { | |||
| 332 | 327 | defines += [ "CPU_NO_SIMD" ] | |
| 333 | 328 | } | |
| 334 | 329 | ||
| 335 | - if (is_ios) { | ||
| 336 | - # iOS@ARM is a special case where we always have NEON but don't check | ||
| 337 | - # for crypto extensions. | ||
| 338 | - # TODO(cavalcantii): verify what is the current state of CPU features | ||
| 339 | - # shipped on latest iOS devices. | ||
| 340 | - defines += [ "ARM_OS_IOS" ] | ||
| 341 | - } | ||
| 342 | - | ||
| 343 | 330 | if (use_x86_x64_optimizations || use_arm_neon_optimizations) { | |
| 344 | 331 | deps += [ | |
| 345 | 332 | ":zlib_adler32_simd", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ URL: http://zlib.net/ | |||
| 4 | 4 | Version: 1.2.13 | |
| 5 | 5 | CPEPrefix: cpe:/a:zlib:zlib:1.2.13 | |
| 6 | 6 | Security Critical: yes | |
| 7 | + Shipped: yes | ||
| 7 | 8 | License: Custom license | |
| 8 | 9 | License File: LICENSE | |
| 9 | 10 | License Android Compatible: yes | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -236,7 +236,11 @@ void check_file(const Data& file, zlib_wrapper type, int mode) { | |||
| 236 | 236 | error_exit("check file: error writing output", 3); | |
| 237 | 237 | } | |
| 238 | 238 | ||
| 239 | - void zlib_file(const char* name, zlib_wrapper type, int width, int check) { | ||
| 239 | + void zlib_file(const char* name, | ||
| 240 | + zlib_wrapper type, | ||
| 241 | + int width, | ||
| 242 | + int check, | ||
| 243 | + bool output_csv_format) { | ||
| 240 | 244 | /* | |
| 241 | 245 | * Read the file data. | |
| 242 | 246 | */ | |
@@ -257,7 +261,9 @@ void zlib_file(const char* name, zlib_wrapper type, int width, int check) { | |||
| 257 | 261 | * Report compression strategy and file name. | |
| 258 | 262 | */ | |
| 259 | 263 | const char* strategy = zlib_level_strategy_name(zlib_compression_level); | |
| 260 | - printf("%s%-40s :\n", strategy, name); | ||
| 264 | + if (!output_csv_format) { | ||
| 265 | + printf("%s%-40s :\n", strategy, name); | ||
| 266 | + } | ||
| 261 | 267 | ||
| 262 | 268 | /* | |
| 263 | 269 | * Chop the data into blocks. | |
@@ -329,19 +335,28 @@ void zlib_file(const char* name, zlib_wrapper type, int width, int check) { | |||
| 329 | 335 | std::sort(ctime, ctime + runs); | |
| 330 | 336 | std::sort(utime, utime + runs); | |
| 331 | 337 | ||
| 332 | - double deflate_rate_med = length * repeats / mega_byte / ctime[runs / 2]; | ||
| 333 | - double inflate_rate_med = length * repeats / mega_byte / utime[runs / 2]; | ||
| 334 | - double deflate_rate_max = length * repeats / mega_byte / ctime[0]; | ||
| 335 | - double inflate_rate_max = length * repeats / mega_byte / utime[0]; | ||
| 336 | - | ||
| 337 | - // type, block size, compression ratio, etc | ||
| 338 | - printf("%s: [b %dM] bytes %*d -> %*u %4.2f%%", | ||
| 339 | - zlib_wrapper_name(type), block_size / (1 << 20), width, length, width, | ||
| 340 | - unsigned(output_length), output_length * 100.0 / length); | ||
| 341 | - | ||
| 342 | - // compress / uncompress median (max) rates | ||
| 343 | - printf(" comp %5.1f (%5.1f) MB/s uncomp %5.1f (%5.1f) MB/s\n", | ||
| 344 | - deflate_rate_med, deflate_rate_max, inflate_rate_med, inflate_rate_max); | ||
| 338 | + double deflate_rate_med, inflate_rate_med, deflate_rate_max, inflate_rate_max; | ||
| 339 | + deflate_rate_med = length * repeats / mega_byte / ctime[runs / 2]; | ||
| 340 | + inflate_rate_med = length * repeats / mega_byte / utime[runs / 2]; | ||
| 341 | + deflate_rate_max = length * repeats / mega_byte / ctime[0]; | ||
| 342 | + inflate_rate_max = length * repeats / mega_byte / utime[0]; | ||
| 343 | + double compress_ratio = output_length * 100.0 / length; | ||
| 344 | + | ||
| 345 | + if (!output_csv_format) { | ||
| 346 | + // type, block size, compression ratio, etc | ||
| 347 | + printf("%s: [b %dM] bytes %*d -> %*u %4.2f%%", zlib_wrapper_name(type), | ||
| 348 | + block_size / (1 << 20), width, length, width, | ||
| 349 | + unsigned(output_length), compress_ratio); | ||
| 350 | + | ||
| 351 | + // compress / uncompress median (max) rates | ||
| 352 | + printf(" comp %5.1f (%5.1f) MB/s uncomp %5.1f (%5.1f) MB/s\n", | ||
| 353 | + deflate_rate_med, deflate_rate_max, inflate_rate_med, | ||
| 354 | + inflate_rate_max); | ||
| 355 | + } else { | ||
| 356 | + printf("%s\t%.5lf\t%.5lf\t%.5lf\t%.5lf\t%.5lf\n", name, deflate_rate_med, | ||
| 357 | + inflate_rate_med, deflate_rate_max, inflate_rate_max, | ||
| 358 | + compress_ratio); | ||
| 359 | + } | ||
| 345 | 360 | } | |
| 346 | 361 | ||
| 347 | 362 | static int argn = 1; | |
@@ -363,8 +378,10 @@ void get_field_width(int argc, char* argv[], int& value) { | |||
| 363 | 378 | } | |
| 364 | 379 | ||
| 365 | 380 | void usage_exit(const char* program) { | |
| 366 | - static auto* options = "gzip|zlib|raw" | ||
| 367 | - " [--compression 0:9] [--huffman|--rle] [--field width] [--check]"; | ||
| 381 | + static auto* options = | ||
| 382 | + "gzip|zlib|raw" | ||
| 383 | + " [--compression 0:9] [--huffman|--rle] [--field width] [--check]" | ||
| 384 | + " [--csv]"; | ||
| 368 | 385 | printf("usage: %s %s files ...\n", program, options); | |
| 369 | 386 | printf("zlib version: %s\n", ZLIB_VERSION); | |
| 370 | 387 | exit(1); | |
@@ -383,7 +400,7 @@ int main(int argc, char* argv[]) { | |||
| 383 | 400 | ||
| 384 | 401 | int size_field_width = 0; | |
| 385 | 402 | int file_check = 0; | |
| 386 | - | ||
| 403 | + bool output_csv = false; | ||
| 387 | 404 | while (argn < argc && argv[argn][0] == '-') { | |
| 388 | 405 | if (get_option(argc, argv, "--compression")) { | |
| 389 | 406 | if (!get_compression(argc, argv, zlib_compression_level)) | |
@@ -398,6 +415,11 @@ int main(int argc, char* argv[]) { | |||
| 398 | 415 | file_check = 2; | |
| 399 | 416 | } else if (get_option(argc, argv, "--field")) { | |
| 400 | 417 | get_field_width(argc, argv, size_field_width); | |
| 418 | + } else if (get_option(argc, argv, "--csv")) { | ||
| 419 | + output_csv = true; | ||
| 420 | + printf( | ||
| 421 | + "filename\tcompression\tdecompression\tcomp_max\t" | ||
| 422 | + "decomp_max\tcompress_ratio\n"); | ||
| 401 | 423 | } else { | |
| 402 | 424 | usage_exit(argv[0]); | |
| 403 | 425 | } | |
@@ -408,8 +430,9 @@ int main(int argc, char* argv[]) { | |||
| 408 | 430 | ||
| 409 | 431 | if (size_field_width < 6) | |
| 410 | 432 | size_field_width = 6; | |
| 411 | - while (argn < argc) | ||
| 412 | - zlib_file(argv[argn++], type, size_field_width, file_check); | ||
| 433 | + while (argn < argc) { | ||
| 434 | + zlib_file(argv[argn++], type, size_field_width, file_check, output_csv); | ||
| 435 | + } | ||
| 413 | 436 | ||
| 414 | 437 | return 0; | |
| 415 | 438 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ URL: https://github.com/madler/zlib/tree/master/contrib/minizip | |||
| 4 | 4 | Version: 1.2.12 | |
| 5 | 5 | License: Zlib | |
| 6 | 6 | Security Critical: yes | |
| 7 | + Shipped: yes | ||
| 7 | 8 | ||
| 8 | 9 | Description: | |
| 9 | 10 | Minizip provides API on top of zlib that can enumerate and extract ZIP archive | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,7 +35,7 @@ int ZLIB_INTERNAL x86_cpu_enable_avx512 = 0; | |||
| 35 | 35 | ||
| 36 | 36 | #ifndef CPU_NO_SIMD | |
| 37 | 37 | ||
| 38 | - #if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) | ||
| 38 | + #if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) || defined(ARMV8_OS_IOS) | ||
| 39 | 39 | #include <pthread.h> | |
| 40 | 40 | #endif | |
| 41 | 41 | ||
@@ -50,17 +50,19 @@ int ZLIB_INTERNAL x86_cpu_enable_avx512 = 0; | |||
| 50 | 50 | #include <zircon/types.h> | |
| 51 | 51 | #elif defined(ARMV8_OS_WINDOWS) || defined(X86_WINDOWS) | |
| 52 | 52 | #include <windows.h> | |
| 53 | + #elif defined(ARMV8_OS_IOS) | ||
| 54 | + #include <sys/sysctl.h> | ||
| 53 | 55 | #elif !defined(_MSC_VER) | |
| 54 | 56 | #include <pthread.h> | |
| 55 | 57 | #else | |
| 56 | 58 | #error cpu_features.c CPU feature detection in not defined for your platform | |
| 57 | 59 | #endif | |
| 58 | 60 | ||
| 59 | - #if !defined(CPU_NO_SIMD) && !defined(ARMV8_OS_MACOS) && !defined(ARM_OS_IOS) | ||
| 61 | + #if !defined(CPU_NO_SIMD) && !defined(ARMV8_OS_MACOS) | ||
| 60 | 62 | static void _cpu_check_features(void); | |
| 61 | 63 | #endif | |
| 62 | 64 | ||
| 63 | - #if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_MACOS) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS) | ||
| 65 | + #if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_MACOS) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS) || defined(ARMV8_OS_IOS) | ||
| 64 | 66 | #if !defined(ARMV8_OS_MACOS) | |
| 65 | 67 | // _cpu_check_features() doesn't need to do anything on mac/arm since all | |
| 66 | 68 | // features are known at build time, so don't call it. | |
@@ -89,11 +91,7 @@ void ZLIB_INTERNAL cpu_check_features(void) | |||
| 89 | 91 | #endif | |
| 90 | 92 | ||
| 91 | 93 | #if (defined(__ARM_NEON__) || defined(__ARM_NEON)) | |
| 92 | - /* | ||
| 93 | - * iOS@ARM is a special case where we always have NEON but don't check | ||
| 94 | - * for crypto extensions. | ||
| 95 | - */ | ||
| 96 | - #if !defined(ARMV8_OS_MACOS) && !defined(ARM_OS_IOS) | ||
| 94 | + #if !defined(ARMV8_OS_MACOS) | ||
| 97 | 95 | /* | |
| 98 | 96 | * See http://bit.ly/2CcoEsr for run-time detection of ARM features and also | |
| 99 | 97 | * crbug.com/931275 for android_getCpuFeatures() use in the Android sandbox. | |
@@ -127,6 +125,18 @@ static void _cpu_check_features(void) | |||
| 127 | 125 | #elif defined(ARMV8_OS_WINDOWS) | |
| 128 | 126 | arm_cpu_enable_crc32 = IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE); | |
| 129 | 127 | arm_cpu_enable_pmull = IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE); | |
| 128 | + #elif defined(ARMV8_OS_IOS) | ||
| 129 | + // Determine what features are supported dynamically. This code is applicable to macOS | ||
| 130 | + // as well if we wish to do that dynamically on that platform in the future. | ||
| 131 | + // See https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics | ||
| 132 | + int val = 0; | ||
| 133 | + size_t len = sizeof(val); | ||
| 134 | + arm_cpu_enable_crc32 = sysctlbyname("hw.optional.armv8_crc32", &val, &len, 0, 0) == 0 | ||
| 135 | + && val != 0; | ||
| 136 | + val = 0; | ||
| 137 | + len = sizeof(val); | ||
| 138 | + arm_cpu_enable_pmull = sysctlbyname("hw.optional.arm.FEAT_PMULL", &val, &len, 0, 0) == 0 | ||
| 139 | + && val != 0; | ||
| 130 | 140 | #endif | |
| 131 | 141 | } | |
| 132 | 142 | #endif | |
| Back | FazBrowse Home | New Git URL |
0 commit comments