dispenso
A library for task parallelism
 
Loading...
Searching...
No Matches
tsan_annotations.cpp
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
9
10#if DISPENSO_HAS_TSAN
11
12#ifdef __GNUC__
13#define ATTRIBUTE_WEAK __attribute__((weak))
14#else
15#define ATTRIBUTE_WEAK
16#endif
17
18// These are found in the accompanying libtsan, but there is no header exposing them. We want to
19// also avoid exposing them in a header to to discourage folks from calling them directly.
20extern "C" {
21void AnnotateIgnoreReadsBegin(const char* f, int l) ATTRIBUTE_WEAK;
22
23void AnnotateIgnoreReadsEnd(const char* f, int l) ATTRIBUTE_WEAK;
24
25void AnnotateIgnoreWritesBegin(const char* f, int l) ATTRIBUTE_WEAK;
26
27void AnnotateIgnoreWritesEnd(const char* f, int l) ATTRIBUTE_WEAK;
28
29void AnnotateNewMemory(const char* f, int l, const volatile void* address, long size)
30 ATTRIBUTE_WEAK;
31
32void AnnotateHappensBefore(const char* f, int l, const volatile void* address) ATTRIBUTE_WEAK;
33void AnnotateHappensAfter(const char* f, int l, const volatile void* address) ATTRIBUTE_WEAK;
34}
35
36namespace dispenso {
37namespace detail {
38
39void annotateIgnoreWritesBegin(const char* f, int l) {
40 AnnotateIgnoreWritesBegin(f, l);
41}
42void annotateIgnoreWritesEnd(const char* f, int l) {
43 AnnotateIgnoreWritesEnd(f, l);
44}
45void annotateIgnoreReadsBegin(const char* f, int l) {
46 AnnotateIgnoreReadsBegin(f, l);
47}
48void annotateIgnoreReadsEnd(const char* f, int l) {
49 AnnotateIgnoreReadsEnd(f, l);
50}
51
52void annotateNewMemory(const char* f, int l, const volatile void* address, long size) {
53 AnnotateNewMemory(f, l, address, size);
54}
55
56void annotateHappensBefore(const char* f, int l, const volatile void* address) {
57 AnnotateHappensBefore(f, l, address);
58}
59
60void annotateHappensAfter(const char* f, int l, const volatile void* address) {
61 AnnotateHappensAfter(f, l, address);
62}
63
64} // namespace detail
65} // namespace dispenso
66
67#endif // TSAN