• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2022 The Abseil Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load(
16    "//absl:copts/configure_copts.bzl",
17    "ABSL_DEFAULT_COPTS",
18    "ABSL_DEFAULT_LINKOPTS",
19    "ABSL_TEST_COPTS",
20)
21
22package(
23    default_visibility = ["//visibility:private"],
24    features = [
25        "header_modules",
26        "layering_check",
27        "parse_headers",
28    ],
29)
30
31licenses(["notice"])
32
33cc_library(
34    name = "cpu_detect",
35    srcs = [
36        "internal/cpu_detect.cc",
37    ],
38    hdrs = ["internal/cpu_detect.h"],
39    copts = ABSL_DEFAULT_COPTS,
40    linkopts = ABSL_DEFAULT_LINKOPTS,
41    visibility = ["//visibility:private"],
42    deps = [
43        "//absl/base",
44        "//absl/base:config",
45    ],
46)
47
48cc_library(
49    name = "crc_internal",
50    srcs = [
51        "internal/crc.cc",
52        "internal/crc_internal.h",
53        "internal/crc_x86_arm_combined.cc",
54    ],
55    hdrs = [
56        "internal/crc.h",
57        "internal/crc32_x86_arm_combined_simd.h",
58    ],
59    copts = ABSL_DEFAULT_COPTS,
60    linkopts = ABSL_DEFAULT_LINKOPTS,
61    visibility = ["//visibility:private"],
62    deps = [
63        ":cpu_detect",
64        "//absl/base:config",
65        "//absl/base:core_headers",
66        "//absl/base:endian",
67        "//absl/base:prefetch",
68        "//absl/base:raw_logging_internal",
69        "//absl/memory",
70        "//absl/numeric:bits",
71    ],
72)
73
74cc_library(
75    name = "crc32c",
76    srcs = [
77        "crc32c.cc",
78        "internal/crc32c_inline.h",
79        "internal/crc_memcpy_fallback.cc",
80        "internal/crc_memcpy_x86_arm_combined.cc",
81        "internal/crc_non_temporal_memcpy.cc",
82    ],
83    hdrs = [
84        "crc32c.h",
85        "internal/crc32c.h",
86        "internal/crc_memcpy.h",
87    ],
88    copts = ABSL_DEFAULT_COPTS,
89    linkopts = ABSL_DEFAULT_LINKOPTS,
90    visibility = ["//visibility:public"],
91    deps = [
92        ":cpu_detect",
93        ":crc_internal",
94        ":non_temporal_memcpy",
95        "//absl/base:config",
96        "//absl/base:core_headers",
97        "//absl/base:endian",
98        "//absl/base:prefetch",
99        "//absl/strings",
100        "//absl/strings:str_format",
101    ],
102)
103
104cc_test(
105    name = "crc32c_test",
106    srcs = ["crc32c_test.cc"],
107    copts = ABSL_TEST_COPTS,
108    linkopts = ABSL_DEFAULT_LINKOPTS,
109    visibility = ["//visibility:private"],
110    deps = [
111        ":crc32c",
112        "//absl/strings",
113        "//absl/strings:str_format",
114        "@com_google_googletest//:gtest",
115        "@com_google_googletest//:gtest_main",
116    ],
117)
118
119cc_library(
120    name = "non_temporal_arm_intrinsics",
121    hdrs = ["internal/non_temporal_arm_intrinsics.h"],
122    copts = ABSL_DEFAULT_COPTS,
123    linkopts = ABSL_DEFAULT_LINKOPTS,
124    visibility = ["//visibility:private"],
125    deps = [
126        "//absl/base:config",
127    ],
128)
129
130cc_library(
131    name = "non_temporal_memcpy",
132    hdrs = ["internal/non_temporal_memcpy.h"],
133    copts = ABSL_DEFAULT_COPTS,
134    linkopts = ABSL_DEFAULT_LINKOPTS,
135    visibility = ["//visibility:private"],
136    deps = [
137        ":non_temporal_arm_intrinsics",
138        "//absl/base:config",
139        "//absl/base:core_headers",
140    ],
141)
142
143cc_test(
144    name = "crc_memcpy_test",
145    size = "large",
146    srcs = ["internal/crc_memcpy_test.cc"],
147    copts = ABSL_TEST_COPTS,
148    linkopts = ABSL_DEFAULT_LINKOPTS,
149    shard_count = 3,
150    visibility = ["//visibility:private"],
151    deps = [
152        ":crc32c",
153        "//absl/memory",
154        "//absl/random",
155        "//absl/random:distributions",
156        "//absl/strings",
157        "@com_google_googletest//:gtest",
158        "@com_google_googletest//:gtest_main",
159    ],
160)
161
162cc_test(
163    name = "non_temporal_memcpy_test",
164    srcs = ["internal/non_temporal_memcpy_test.cc"],
165    copts = ABSL_TEST_COPTS,
166    linkopts = ABSL_DEFAULT_LINKOPTS,
167    visibility = ["//visibility:private"],
168    deps = [
169        ":non_temporal_memcpy",
170        "@com_google_googletest//:gtest",
171        "@com_google_googletest//:gtest_main",
172    ],
173)
174
175cc_library(
176    name = "crc_cord_state",
177    srcs = ["internal/crc_cord_state.cc"],
178    hdrs = ["internal/crc_cord_state.h"],
179    copts = ABSL_DEFAULT_COPTS,
180    linkopts = ABSL_DEFAULT_LINKOPTS,
181    visibility = ["//absl/strings:__pkg__"],
182    deps = [
183        ":crc32c",
184        "//absl/base:config",
185        "//absl/numeric:bits",
186        "//absl/strings",
187    ],
188)
189
190cc_test(
191    name = "crc_cord_state_test",
192    srcs = ["internal/crc_cord_state_test.cc"],
193    copts = ABSL_TEST_COPTS,
194    linkopts = ABSL_DEFAULT_LINKOPTS,
195    visibility = ["//visibility:private"],
196    deps = [
197        ":crc32c",
198        ":crc_cord_state",
199        "@com_google_googletest//:gtest",
200        "@com_google_googletest//:gtest_main",
201    ],
202)
203
204cc_binary(
205    name = "crc32c_benchmark",
206    testonly = 1,
207    srcs = ["crc32c_benchmark.cc"],
208    copts = ABSL_TEST_COPTS,
209    linkopts = ABSL_DEFAULT_LINKOPTS,
210    tags = [
211        "benchmark",
212    ],
213    visibility = ["//visibility:private"],
214    deps = [
215        ":crc32c",
216        "//absl/memory",
217        "//absl/strings",
218        "@com_github_google_benchmark//:benchmark_main",
219    ],
220)
221