/Users/deen/code/yugabyte-db/src/yb/util/tsan_util.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_UTIL_TSAN_UTIL_H |
15 | | #define YB_UTIL_TSAN_UTIL_H |
16 | | |
17 | | namespace yb { |
18 | | |
19 | | template <class T> |
20 | 527 | constexpr T NonTsanVsTsan(T value_not_in_tsan, T value_in_tsan) { |
21 | | #if THREAD_SANITIZER |
22 | | return value_in_tsan; |
23 | | #else |
24 | 527 | return value_not_in_tsan; |
25 | 527 | #endif |
26 | 527 | } bool yb::NonTsanVsTsan<bool>(bool, bool) Line | Count | Source | 20 | 442 | constexpr T NonTsanVsTsan(T value_not_in_tsan, T value_in_tsan) { | 21 | | #if THREAD_SANITIZER | 22 | | return value_in_tsan; | 23 | | #else | 24 | 442 | return value_not_in_tsan; | 25 | 442 | #endif | 26 | 442 | } |
Unexecuted instantiation: unsigned long yb::NonTsanVsTsan<unsigned long>(unsigned long, unsigned long) int yb::NonTsanVsTsan<int>(int, int) Line | Count | Source | 20 | 85 | constexpr T NonTsanVsTsan(T value_not_in_tsan, T value_in_tsan) { | 21 | | #if THREAD_SANITIZER | 22 | | return value_in_tsan; | 23 | | #else | 24 | 85 | return value_not_in_tsan; | 25 | 85 | #endif | 26 | 85 | } |
|
27 | | |
28 | 441 | constexpr bool IsTsan() { |
29 | 441 | return NonTsanVsTsan(false, true); |
30 | 441 | } |
31 | | |
32 | | template <class T> |
33 | 34 | constexpr T RegularBuildVsSanitizers(T regular_build_value, T sanitizer_value) { |
34 | | #if defined(THREAD_SANITIZER) || defined(ADDRESS_SANITIZER) |
35 | | return sanitizer_value; |
36 | | #else |
37 | 34 | return regular_build_value; |
38 | 34 | #endif |
39 | 34 | } Unexecuted instantiation: std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> > yb::RegularBuildVsSanitizers<std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> > >(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> >, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> >) std::__1::chrono::duration<long long, std::__1::ratio<1l, 1l> > yb::RegularBuildVsSanitizers<std::__1::chrono::duration<long long, std::__1::ratio<1l, 1l> > >(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1l> >, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1l> >) Line | Count | Source | 33 | 34 | constexpr T RegularBuildVsSanitizers(T regular_build_value, T sanitizer_value) { | 34 | | #if defined(THREAD_SANITIZER) || defined(ADDRESS_SANITIZER) | 35 | | return sanitizer_value; | 36 | | #else | 37 | 34 | return regular_build_value; | 38 | 34 | #endif | 39 | 34 | } |
|
40 | | |
41 | | template <class T> |
42 | | constexpr T RegularBuildVsDebugVsSanitizers( |
43 | | T regular_build_value, T debug_build_value, T sanitizer_value) { |
44 | | #if defined(THREAD_SANITIZER) || defined(ADDRESS_SANITIZER) |
45 | | return sanitizer_value; |
46 | | #elif defined(NDEBUG) |
47 | | return regular_build_value; |
48 | | #else |
49 | | return debug_build_value; |
50 | | #endif |
51 | | } |
52 | | |
53 | 0 | constexpr bool IsSanitizer() { |
54 | 0 | return RegularBuildVsSanitizers(false, true); |
55 | 0 | } |
56 | | |
57 | | const int kTimeMultiplier = RegularBuildVsSanitizers(1, 3); |
58 | | |
59 | | } // namespace yb |
60 | | |
61 | | #endif // YB_UTIL_TSAN_UTIL_H |