[TySan] Don't report globals with incomplete types. (#121922)
[llvm-project.git] / compiler-rt / lib / scudo / standalone / condition_variable_base.h
blob416c327fed49ef8215aebe544e90ea1139a15d7e
1 //===-- condition_variable_base.h -------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef SCUDO_CONDITION_VARIABLE_BASE_H_
10 #define SCUDO_CONDITION_VARIABLE_BASE_H_
12 #include "mutex.h"
13 #include "thread_annotations.h"
15 namespace scudo {
17 template <typename Derived> class ConditionVariableBase {
18 public:
19 constexpr ConditionVariableBase() = default;
21 void bindTestOnly(HybridMutex &Mutex) {
22 #if SCUDO_DEBUG
23 boundMutex = &Mutex;
24 #else
25 (void)Mutex;
26 #endif
29 void notifyAll(HybridMutex &M) REQUIRES(M) {
30 #if SCUDO_DEBUG
31 CHECK_EQ(&M, boundMutex);
32 #endif
33 getDerived()->notifyAllImpl(M);
36 void wait(HybridMutex &M) REQUIRES(M) {
37 #if SCUDO_DEBUG
38 CHECK_EQ(&M, boundMutex);
39 #endif
40 getDerived()->waitImpl(M);
43 protected:
44 Derived *getDerived() { return static_cast<Derived *>(this); }
46 #if SCUDO_DEBUG
47 // Because thread-safety analysis doesn't support pointer aliasing, we are not
48 // able to mark the proper annotations without false positive. Instead, we
49 // pass the lock and do the same-lock check separately.
50 HybridMutex *boundMutex = nullptr;
51 #endif
54 } // namespace scudo
56 #endif // SCUDO_CONDITION_VARIABLE_BASE_H_