xref: /aosp_15_r20/external/grpc-grpc/test/core/util/build.cc (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1 // Copyright 2021 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
BuiltUnderValgrind()15 bool BuiltUnderValgrind() {
16 #ifdef RUNNING_ON_VALGRIND
17   return true;
18 #else
19   return false;
20 #endif
21 }
22 
BuiltUnderTsan()23 bool BuiltUnderTsan() {
24 #if defined(__has_feature)
25 #if __has_feature(thread_sanitizer)
26   return true;
27 #else
28   return false;
29 #endif
30 #else
31 #ifdef THREAD_SANITIZER
32   return true;
33 #else
34   return false;
35 #endif
36 #endif
37 }
38 
BuiltUnderAsan()39 bool BuiltUnderAsan() {
40 #if defined(__has_feature)
41 #if __has_feature(address_sanitizer)
42   return true;
43 #else
44   return false;
45 #endif
46 #else
47 #ifdef ADDRESS_SANITIZER
48   return true;
49 #else
50   return false;
51 #endif
52 #endif
53 }
54 
BuiltUnderMsan()55 bool BuiltUnderMsan() {
56 #if defined(__has_feature)
57 #if __has_feature(memory_sanitizer)
58   return true;
59 #else
60   return false;
61 #endif
62 #else
63 #ifdef MEMORY_SANITIZER
64   return true;
65 #else
66   return false;
67 #endif
68 #endif
69 }
70 
BuiltUnderUbsan()71 bool BuiltUnderUbsan() {
72 #ifdef GRPC_UBSAN
73   return true;
74 #else
75   return false;
76 #endif
77 }
78