1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file |
2 | // for details. All rights reserved. Use of this source code is governed by a |
3 | // BSD-style license that can be found in the LICENSE file. |
4 | |
5 | #ifndef RUNTIME_PLATFORM_LEAK_SANITIZER_H_ |
6 | #define RUNTIME_PLATFORM_LEAK_SANITIZER_H_ |
7 | |
8 | #include "platform/globals.h" |
9 | |
10 | #if defined(__has_feature) |
11 | #if __has_feature(leak_sanitizer) || __has_feature(address_sanitizer) |
12 | #define USING_LEAK_SANITIZER |
13 | #endif |
14 | #endif |
15 | |
16 | #if defined(USING_LEAK_SANITIZER) |
17 | extern "C" void __lsan_register_root_region(const void* p, size_t size); |
18 | extern "C" void __lsan_unregister_root_region(const void* p, size_t size); |
19 | #define LSAN_REGISTER_ROOT_REGION(ptr, len) \ |
20 | __lsan_register_root_region(ptr, len) |
21 | #define LSAN_UNREGISTER_ROOT_REGION(ptr, len) \ |
22 | __lsan_unregister_root_region(ptr, len) |
23 | #else // defined(USING_LEAK_SANITIZER) |
24 | #define LSAN_REGISTER_ROOT_REGION(ptr, len) \ |
25 | do { \ |
26 | } while (false && (ptr) == 0 && (len) == 0) |
27 | #define LSAN_UNREGISTER_ROOT_REGION(ptr, len) \ |
28 | do { \ |
29 | } while (false && (ptr) == 0 && (len) == 0) |
30 | #endif // defined(USING_LEAK_SANITIZER) |
31 | |
32 | #endif // RUNTIME_PLATFORM_LEAK_SANITIZER_H_ |
33 | |