Skip to content

Commit

Permalink
Rebase and add Rabin–Karp algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex313031 committed Apr 30, 2022
1 parent 620374a commit 3cef06b
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions third_party/zlib/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Copyright (c) 2022 The Chromium Authors and Alex313031. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand All @@ -21,7 +21,7 @@ config("zlib_internal_config") {

if (!is_debug) {
# Build code using -O3, see: crbug.com/1084371.
# configs = [ "//build/config/compiler:optimize_speed" ]
configs = [ "//build/config/compiler:optimize_speed" ]
}
if (is_debug || use_libfuzzer) {
# Enable zlib's asserts in debug and fuzzer builds.
Expand Down Expand Up @@ -216,6 +216,7 @@ source_set("zlib_crc32_simd") {
sources = [
"crc32_simd.c",
"crc32_simd.h",
"crc_folding.c",
]

if (!is_win || is_clang) {
Expand All @@ -229,38 +230,34 @@ source_set("zlib_crc32_simd") {
configs += [ ":zlib_internal_config" ]

public_configs = [ ":zlib_crc32_simd_config" ]

public_deps = [ ":zlib_common_headers" ]
}

config("zlib_x86_simd_config") {
config("zlib_slide_hash_simd_config") {
if (use_x86_x64_optimizations) {
defines = [
"CRC32_SIMD_SSE42_PCLMUL",
"DEFLATE_FILL_WINDOW_SSE2",
]
defines = [ "DEFLATE_SLIDE_HASH_SSE2" ]
}

if (use_arm_neon_optimizations) {
defines = [ "DEFLATE_SLIDE_HASH_NEON" ]
}
}

source_set("zlib_x86_simd") {
source_set("zlib_slide_hash_simd") {
visibility = [ ":*" ]

if (use_x86_x64_optimizations) {
sources = [
"crc_folding.c",
"fill_window_sse.c",
]
sources = [ "slide_hash_simd.h" ]
}

if (!is_win || is_clang) {
cflags = [
"-msse4.2",
"-mpclmul",
]
}
if (use_arm_neon_optimizations) {
sources = [ "slide_hash_simd.h" ]
}

configs += [ ":zlib_internal_config" ]

public_configs = [ ":zlib_x86_simd_config" ]
public_configs = [ ":zlib_slide_hash_simd_config" ]

public_deps = [ ":zlib_common_headers" ]
}
Expand Down Expand Up @@ -330,20 +327,18 @@ component("zlib") {
deps += [
":zlib_adler32_simd",
":zlib_inflate_chunk_simd",
":zlib_slide_hash_simd",
]

if (use_x86_x64_optimizations) {
deps += [ ":zlib_crc32_simd" ]
} else if (use_arm_neon_optimizations) {
sources += [ "contrib/optimizations/slide_hash_neon.h" ]
deps += [ ":zlib_arm_crc32" ]
}
} else {
sources += [ "inflate.c" ]
}

deps += [ ":zlib_x86_simd" ]

if (is_android) {
import("//build/config/android/config.gni")
if (defined(android_ndk_root) && android_ndk_root != "") {
Expand Down

0 comments on commit 3cef06b

Please sign in to comment.