blob: cd4009a157396d73a5c2dee8edbe1950338e9076 [file] [log] [blame]
Austin Schuh36244a12019-09-21 17:52:38 -07001#
2# Copyright 2017 The Abseil Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
18load(
19 "//absl:copts/configure_copts.bzl",
20 "ABSL_DEFAULT_COPTS",
21 "ABSL_DEFAULT_LINKOPTS",
22 "ABSL_TEST_COPTS",
23)
24
25package(default_visibility = ["//visibility:public"])
26
Austin Schuhb4691e92020-12-31 12:37:18 -080027licenses(["notice"])
Austin Schuh36244a12019-09-21 17:52:38 -070028
29# Internal data structure for efficiently detecting mutex dependency cycles
30cc_library(
31 name = "graphcycles_internal",
32 srcs = [
33 "internal/graphcycles.cc",
34 ],
35 hdrs = [
36 "internal/graphcycles.h",
37 ],
38 copts = ABSL_DEFAULT_COPTS,
39 linkopts = ABSL_DEFAULT_LINKOPTS,
40 visibility = [
41 "//absl:__subpackages__",
42 ],
43 deps = [
44 "//absl/base",
45 "//absl/base:base_internal",
Austin Schuhb4691e92020-12-31 12:37:18 -080046 "//absl/base:config",
Austin Schuh36244a12019-09-21 17:52:38 -070047 "//absl/base:core_headers",
48 "//absl/base:malloc_internal",
49 "//absl/base:raw_logging_internal",
50 ],
51)
52
53cc_library(
54 name = "kernel_timeout_internal",
55 hdrs = ["internal/kernel_timeout.h"],
56 copts = ABSL_DEFAULT_COPTS,
57 linkopts = ABSL_DEFAULT_LINKOPTS,
58 visibility = [
59 "//absl/synchronization:__pkg__",
60 ],
61 deps = [
62 "//absl/base:core_headers",
63 "//absl/base:raw_logging_internal",
64 "//absl/time",
65 ],
66)
67
68cc_library(
69 name = "synchronization",
70 srcs = [
71 "barrier.cc",
72 "blocking_counter.cc",
73 "internal/create_thread_identity.cc",
74 "internal/per_thread_sem.cc",
75 "internal/waiter.cc",
Austin Schuhb4691e92020-12-31 12:37:18 -080076 "mutex.cc",
Austin Schuh36244a12019-09-21 17:52:38 -070077 "notification.cc",
Austin Schuhb4691e92020-12-31 12:37:18 -080078 ],
Austin Schuh36244a12019-09-21 17:52:38 -070079 hdrs = [
80 "barrier.h",
81 "blocking_counter.h",
82 "internal/create_thread_identity.h",
Austin Schuhb4691e92020-12-31 12:37:18 -080083 "internal/futex.h",
Austin Schuh36244a12019-09-21 17:52:38 -070084 "internal/per_thread_sem.h",
85 "internal/waiter.h",
86 "mutex.h",
87 "notification.h",
88 ],
89 copts = ABSL_DEFAULT_COPTS,
90 linkopts = select({
91 "//absl:windows": [],
Austin Schuhb4691e92020-12-31 12:37:18 -080092 "//absl:wasm": [],
Austin Schuh36244a12019-09-21 17:52:38 -070093 "//conditions:default": ["-pthread"],
94 }) + ABSL_DEFAULT_LINKOPTS,
95 deps = [
96 ":graphcycles_internal",
97 ":kernel_timeout_internal",
98 "//absl/base",
99 "//absl/base:atomic_hook",
100 "//absl/base:base_internal",
101 "//absl/base:config",
102 "//absl/base:core_headers",
103 "//absl/base:dynamic_annotations",
104 "//absl/base:malloc_internal",
105 "//absl/base:raw_logging_internal",
106 "//absl/debugging:stacktrace",
107 "//absl/debugging:symbolize",
108 "//absl/time",
109 ],
110)
111
112cc_test(
113 name = "barrier_test",
114 size = "small",
115 srcs = ["barrier_test.cc"],
116 copts = ABSL_TEST_COPTS,
117 linkopts = ABSL_DEFAULT_LINKOPTS,
118 deps = [
119 ":synchronization",
120 "//absl/time",
121 "@com_google_googletest//:gtest_main",
122 ],
123)
124
125cc_test(
126 name = "blocking_counter_test",
127 size = "small",
128 srcs = ["blocking_counter_test.cc"],
129 copts = ABSL_TEST_COPTS,
130 linkopts = ABSL_DEFAULT_LINKOPTS,
131 deps = [
132 ":synchronization",
133 "//absl/time",
134 "@com_google_googletest//:gtest_main",
135 ],
136)
137
138cc_test(
139 name = "graphcycles_test",
140 size = "medium",
141 srcs = ["internal/graphcycles_test.cc"],
142 copts = ABSL_TEST_COPTS,
143 linkopts = ABSL_DEFAULT_LINKOPTS,
144 deps = [
145 ":graphcycles_internal",
146 "//absl/base:core_headers",
147 "//absl/base:raw_logging_internal",
148 "@com_google_googletest//:gtest_main",
149 ],
150)
151
152cc_test(
153 name = "graphcycles_benchmark",
154 srcs = ["internal/graphcycles_benchmark.cc"],
155 copts = ABSL_TEST_COPTS,
156 linkopts = ABSL_DEFAULT_LINKOPTS,
157 tags = [
158 "benchmark",
159 ],
160 deps = [
161 ":graphcycles_internal",
162 "//absl/base:raw_logging_internal",
163 "@com_github_google_benchmark//:benchmark_main",
164 ],
165)
166
167cc_library(
168 name = "thread_pool",
169 testonly = 1,
170 hdrs = ["internal/thread_pool.h"],
171 linkopts = ABSL_DEFAULT_LINKOPTS,
172 visibility = [
173 "//absl:__subpackages__",
174 ],
175 deps = [
176 ":synchronization",
177 "//absl/base:core_headers",
178 ],
179)
180
181cc_test(
182 name = "mutex_test",
183 size = "large",
184 srcs = ["mutex_test.cc"],
185 copts = ABSL_TEST_COPTS,
186 linkopts = ABSL_DEFAULT_LINKOPTS,
187 shard_count = 25,
188 deps = [
189 ":synchronization",
190 ":thread_pool",
191 "//absl/base",
Austin Schuhb4691e92020-12-31 12:37:18 -0800192 "//absl/base:config",
Austin Schuh36244a12019-09-21 17:52:38 -0700193 "//absl/base:core_headers",
194 "//absl/base:raw_logging_internal",
195 "//absl/memory",
196 "//absl/time",
197 "@com_google_googletest//:gtest_main",
198 ],
199)
200
201cc_library(
202 name = "mutex_benchmark_common",
203 testonly = 1,
204 srcs = ["mutex_benchmark.cc"],
205 copts = ABSL_TEST_COPTS,
206 linkopts = ABSL_DEFAULT_LINKOPTS,
207 visibility = [
208 "//absl/synchronization:__pkg__",
209 ],
210 deps = [
211 ":synchronization",
212 ":thread_pool",
213 "//absl/base",
Austin Schuhb4691e92020-12-31 12:37:18 -0800214 "//absl/base:config",
Austin Schuh36244a12019-09-21 17:52:38 -0700215 "@com_github_google_benchmark//:benchmark_main",
216 ],
217 alwayslink = 1,
218)
219
220cc_binary(
221 name = "mutex_benchmark",
222 testonly = 1,
223 copts = ABSL_DEFAULT_COPTS,
224 linkopts = ABSL_DEFAULT_LINKOPTS,
225 visibility = ["//visibility:private"],
226 deps = [
227 ":mutex_benchmark_common",
228 ],
229)
230
231cc_test(
232 name = "notification_test",
233 size = "small",
234 srcs = ["notification_test.cc"],
235 copts = ABSL_TEST_COPTS,
236 linkopts = ABSL_DEFAULT_LINKOPTS,
237 deps = [
238 ":synchronization",
239 "//absl/time",
240 "@com_google_googletest//:gtest_main",
241 ],
242)
243
244cc_library(
245 name = "per_thread_sem_test_common",
246 testonly = 1,
247 srcs = ["internal/per_thread_sem_test.cc"],
248 copts = ABSL_TEST_COPTS,
249 linkopts = ABSL_DEFAULT_LINKOPTS,
250 deps = [
251 ":synchronization",
252 "//absl/base",
Austin Schuhb4691e92020-12-31 12:37:18 -0800253 "//absl/base:config",
Austin Schuh36244a12019-09-21 17:52:38 -0700254 "//absl/strings",
255 "//absl/time",
256 "@com_google_googletest//:gtest",
257 ],
258 alwayslink = 1,
259)
260
261cc_test(
262 name = "per_thread_sem_test",
263 size = "medium",
264 copts = ABSL_TEST_COPTS,
265 linkopts = ABSL_DEFAULT_LINKOPTS,
266 deps = [
267 ":per_thread_sem_test_common",
268 ":synchronization",
269 "//absl/strings",
270 "//absl/time",
271 "@com_google_googletest//:gtest_main",
272 ],
273)
274
275cc_test(
276 name = "lifetime_test",
277 srcs = [
278 "lifetime_test.cc",
279 ],
280 copts = ABSL_TEST_COPTS,
281 linkopts = ABSL_DEFAULT_LINKOPTS,
282 tags = ["no_test_ios_x86_64"],
283 deps = [
284 ":synchronization",
285 "//absl/base:core_headers",
286 "//absl/base:raw_logging_internal",
287 ],
288)