blob: 36dc98f39e7a54f737861112f72b7927b372b131 [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
27licenses(["notice"]) # Apache 2.0
28
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",
46 "//absl/base:core_headers",
47 "//absl/base:malloc_internal",
48 "//absl/base:raw_logging_internal",
49 ],
50)
51
52cc_library(
53 name = "kernel_timeout_internal",
54 hdrs = ["internal/kernel_timeout.h"],
55 copts = ABSL_DEFAULT_COPTS,
56 linkopts = ABSL_DEFAULT_LINKOPTS,
57 visibility = [
58 "//absl/synchronization:__pkg__",
59 ],
60 deps = [
61 "//absl/base:core_headers",
62 "//absl/base:raw_logging_internal",
63 "//absl/time",
64 ],
65)
66
67cc_library(
68 name = "synchronization",
69 srcs = [
70 "barrier.cc",
71 "blocking_counter.cc",
72 "internal/create_thread_identity.cc",
73 "internal/per_thread_sem.cc",
74 "internal/waiter.cc",
75 "notification.cc",
76 ] + select({
77 "//conditions:default": ["mutex.cc"],
78 }),
79 hdrs = [
80 "barrier.h",
81 "blocking_counter.h",
82 "internal/create_thread_identity.h",
83 "internal/mutex_nonprod.inc",
84 "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": [],
92 "//conditions:default": ["-pthread"],
93 }) + ABSL_DEFAULT_LINKOPTS,
94 deps = [
95 ":graphcycles_internal",
96 ":kernel_timeout_internal",
97 "//absl/base",
98 "//absl/base:atomic_hook",
99 "//absl/base:base_internal",
100 "//absl/base:config",
101 "//absl/base:core_headers",
102 "//absl/base:dynamic_annotations",
103 "//absl/base:malloc_internal",
104 "//absl/base:raw_logging_internal",
105 "//absl/debugging:stacktrace",
106 "//absl/debugging:symbolize",
107 "//absl/time",
108 ],
109)
110
111cc_test(
112 name = "barrier_test",
113 size = "small",
114 srcs = ["barrier_test.cc"],
115 copts = ABSL_TEST_COPTS,
116 linkopts = ABSL_DEFAULT_LINKOPTS,
117 deps = [
118 ":synchronization",
119 "//absl/time",
120 "@com_google_googletest//:gtest_main",
121 ],
122)
123
124cc_test(
125 name = "blocking_counter_test",
126 size = "small",
127 srcs = ["blocking_counter_test.cc"],
128 copts = ABSL_TEST_COPTS,
129 linkopts = ABSL_DEFAULT_LINKOPTS,
130 deps = [
131 ":synchronization",
132 "//absl/time",
133 "@com_google_googletest//:gtest_main",
134 ],
135)
136
137cc_test(
138 name = "graphcycles_test",
139 size = "medium",
140 srcs = ["internal/graphcycles_test.cc"],
141 copts = ABSL_TEST_COPTS,
142 linkopts = ABSL_DEFAULT_LINKOPTS,
143 deps = [
144 ":graphcycles_internal",
145 "//absl/base:core_headers",
146 "//absl/base:raw_logging_internal",
147 "@com_google_googletest//:gtest_main",
148 ],
149)
150
151cc_test(
152 name = "graphcycles_benchmark",
153 srcs = ["internal/graphcycles_benchmark.cc"],
154 copts = ABSL_TEST_COPTS,
155 linkopts = ABSL_DEFAULT_LINKOPTS,
156 tags = [
157 "benchmark",
158 ],
159 deps = [
160 ":graphcycles_internal",
161 "//absl/base:raw_logging_internal",
162 "@com_github_google_benchmark//:benchmark_main",
163 ],
164)
165
166cc_library(
167 name = "thread_pool",
168 testonly = 1,
169 hdrs = ["internal/thread_pool.h"],
170 linkopts = ABSL_DEFAULT_LINKOPTS,
171 visibility = [
172 "//absl:__subpackages__",
173 ],
174 deps = [
175 ":synchronization",
176 "//absl/base:core_headers",
177 ],
178)
179
180cc_test(
181 name = "mutex_test",
182 size = "large",
183 srcs = ["mutex_test.cc"],
184 copts = ABSL_TEST_COPTS,
185 linkopts = ABSL_DEFAULT_LINKOPTS,
186 shard_count = 25,
187 deps = [
188 ":synchronization",
189 ":thread_pool",
190 "//absl/base",
191 "//absl/base:core_headers",
192 "//absl/base:raw_logging_internal",
193 "//absl/memory",
194 "//absl/time",
195 "@com_google_googletest//:gtest_main",
196 ],
197)
198
199cc_library(
200 name = "mutex_benchmark_common",
201 testonly = 1,
202 srcs = ["mutex_benchmark.cc"],
203 copts = ABSL_TEST_COPTS,
204 linkopts = ABSL_DEFAULT_LINKOPTS,
205 visibility = [
206 "//absl/synchronization:__pkg__",
207 ],
208 deps = [
209 ":synchronization",
210 ":thread_pool",
211 "//absl/base",
212 "@com_github_google_benchmark//:benchmark_main",
213 ],
214 alwayslink = 1,
215)
216
217cc_binary(
218 name = "mutex_benchmark",
219 testonly = 1,
220 copts = ABSL_DEFAULT_COPTS,
221 linkopts = ABSL_DEFAULT_LINKOPTS,
222 visibility = ["//visibility:private"],
223 deps = [
224 ":mutex_benchmark_common",
225 ],
226)
227
228cc_test(
229 name = "notification_test",
230 size = "small",
231 srcs = ["notification_test.cc"],
232 copts = ABSL_TEST_COPTS,
233 linkopts = ABSL_DEFAULT_LINKOPTS,
234 deps = [
235 ":synchronization",
236 "//absl/time",
237 "@com_google_googletest//:gtest_main",
238 ],
239)
240
241cc_library(
242 name = "per_thread_sem_test_common",
243 testonly = 1,
244 srcs = ["internal/per_thread_sem_test.cc"],
245 copts = ABSL_TEST_COPTS,
246 linkopts = ABSL_DEFAULT_LINKOPTS,
247 deps = [
248 ":synchronization",
249 "//absl/base",
250 "//absl/strings",
251 "//absl/time",
252 "@com_google_googletest//:gtest",
253 ],
254 alwayslink = 1,
255)
256
257cc_test(
258 name = "per_thread_sem_test",
259 size = "medium",
260 copts = ABSL_TEST_COPTS,
261 linkopts = ABSL_DEFAULT_LINKOPTS,
262 deps = [
263 ":per_thread_sem_test_common",
264 ":synchronization",
265 "//absl/strings",
266 "//absl/time",
267 "@com_google_googletest//:gtest_main",
268 ],
269)
270
271cc_test(
272 name = "lifetime_test",
273 srcs = [
274 "lifetime_test.cc",
275 ],
276 copts = ABSL_TEST_COPTS,
277 linkopts = ABSL_DEFAULT_LINKOPTS,
278 tags = ["no_test_ios_x86_64"],
279 deps = [
280 ":synchronization",
281 "//absl/base:core_headers",
282 "//absl/base:raw_logging_internal",
283 ],
284)