proxygen
SanitizeThread.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2013-present Facebook, Inc.
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  * http://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 
18 
19 // abseil uses size_t for size params while other FB code and libraries use
20 // long, so it is helpful to keep these declarations out of widely-included
21 // header files.
22 
23 extern "C" FOLLY_ATTR_WEAK void
24 AnnotateRWLockCreate(const char* f, int l, const volatile void* addr);
25 
26 extern "C" FOLLY_ATTR_WEAK void
27 AnnotateRWLockCreateStatic(const char* f, int l, const volatile void* addr);
28 
29 extern "C" FOLLY_ATTR_WEAK void
30 AnnotateRWLockDestroy(const char* f, int l, const volatile void* addr);
31 
32 extern "C" FOLLY_ATTR_WEAK void
33 AnnotateRWLockAcquired(const char* f, int l, const volatile void* addr, long w);
34 
35 extern "C" FOLLY_ATTR_WEAK void
36 AnnotateRWLockReleased(const char* f, int l, const volatile void* addr, long w);
37 
39  const char* f,
40  int l,
41  const volatile void* addr,
42  long size,
43  const char* desc);
44 
45 namespace {
46 void do_nothing(...) {}
47 } // namespace
48 
49 #if _MSC_VER
50 #define FOLLY_SANITIZE_THREAD_CALL_HOOK(name, ...) do_nothing(__VA_ARGS__)
51 #else
52 #define FOLLY_SANITIZE_THREAD_CALL_HOOK(name, ...) name(__VA_ARGS__)
53 #endif
54 
55 namespace folly {
56 namespace detail {
57 
59  void const volatile* const addr,
60  char const* const f,
61  int const l) {
62  if (kIsSanitizeThread) {
64  }
65 }
66 
68  void const volatile* const addr,
69  char const* const f,
70  int const l) {
71  if (kIsSanitizeThread) {
73  }
74 }
75 
77  void const volatile* const addr,
78  char const* const f,
79  int const l) {
80  if (kIsSanitizeThread) {
82  }
83 }
84 
86  void const volatile* const addr,
87  annotate_rwlock_level const w,
88  char const* const f,
89  int const l) {
90  if (kIsSanitizeThread) {
92  AnnotateRWLockAcquired, f, l, addr, static_cast<long>(w));
93  }
94 }
95 
97  void const volatile* const addr,
98  annotate_rwlock_level const w,
99  bool const result,
100  char const* const f,
101  int const l) {
102  if (result) {
103  annotate_rwlock_acquired(addr, w, f, l);
104  }
105 }
106 
108  void const volatile* const addr,
109  annotate_rwlock_level const w,
110  char const* const f,
111  int const l) {
112  if (kIsSanitizeThread) {
114  AnnotateRWLockReleased, f, l, addr, static_cast<long>(w));
115  }
116 }
117 
119  const volatile void* addr,
120  long size,
121  const char* desc,
122  const char* f,
123  int l) {
124  if (kIsSanitizeThread) {
126  AnnotateBenignRaceSized, f, l, addr, size, desc);
127  }
128 }
129 } // namespace detail
130 } // namespace folly
void annotate_rwlock_released_impl(void const volatile *const addr, annotate_rwlock_level const w, char const *const f, int const l)
#define FOLLY_SANITIZE_THREAD_CALL_HOOK(name,...)
#define FOLLY_ATTR_WEAK
Definition: CPortability.h:167
FOLLY_ATTR_WEAK void AnnotateRWLockCreateStatic(const char *f, int l, const volatile void *addr)
auto f
void annotate_rwlock_acquired_impl(void const volatile *const addr, annotate_rwlock_level const w, char const *const f, int const l)
constexpr bool kIsSanitizeThread
Definition: Portability.h:124
void annotate_benign_race_sized_impl(const volatile void *addr, long size, const char *desc, const char *f, int l)
FOLLY_ATTR_WEAK void AnnotateRWLockReleased(const char *f, int l, const volatile void *addr, long w)
void annotate_rwlock_destroy_impl(void const volatile *const addr, char const *const f, int const l)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
void annotate_rwlock_create_impl(void const volatile *const addr, char const *const f, int const l)
FOLLY_ATTR_WEAK void AnnotateRWLockAcquired(const char *f, int l, const volatile void *addr, long w)
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
FOLLY_ATTR_WEAK void AnnotateRWLockCreate(const char *f, int l, const volatile void *addr)
void annotate_rwlock_try_acquired_impl(void const volatile *const addr, annotate_rwlock_level const w, bool const result, char const *const f, int const l)
void annotate_rwlock_create_static_impl(void const volatile *const addr, char const *const f, int const l)
static FOLLY_ALWAYS_INLINE void annotate_rwlock_acquired(void const volatile *const addr, annotate_rwlock_level const w, char const *const f, int const l)
FOLLY_ATTR_WEAK void AnnotateRWLockDestroy(const char *f, int l, const volatile void *addr)
ThreadPoolListHook * addr
annotate_rwlock_level
FOLLY_ATTR_WEAK void AnnotateBenignRaceSized(const char *f, int l, const volatile void *addr, long size, const char *desc)