1 | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved. |
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 | ==============================================================================*/ |
15 | |
16 | #include "pybind11/pybind11.h" |
17 | |
18 | // Check if specific santizers are enabled. |
19 | PYBIND11_MODULE(_pywrap_sanitizers, m) { |
20 | m.def("is_asan_enabled" , []() -> bool { |
21 | #if defined(ADDRESS_SANITIZER) |
22 | return true; |
23 | #else |
24 | return false; |
25 | #endif |
26 | }); |
27 | |
28 | m.def("is_msan_enabled" , []() -> bool { |
29 | #if defined(MEMORY_SANITIZER) |
30 | return true; |
31 | #else |
32 | return false; |
33 | #endif |
34 | }); |
35 | |
36 | m.def("is_tsan_enabled" , []() -> bool { |
37 | #if defined(THREAD_SANITIZER) |
38 | return true; |
39 | #else |
40 | return false; |
41 | #endif |
42 | }); |
43 | |
44 | m.def("is_ubsan_enabled" , []() -> bool { |
45 | #if defined(UNDEFINED_BEHAVIOR_SANITIZER) |
46 | return true; |
47 | #else |
48 | return false; |
49 | #endif |
50 | }); |
51 | } |
52 | |