xref: /aosp_15_r20/external/libbrillo/brillo/asan.h (revision 1a96fba65179ea7d3f56207137718607415c5953)
1*1a96fba6SXin Li // Copyright 2018 The Chromium OS Authors. All rights reserved.
2*1a96fba6SXin Li // Use of this source code is governed by a BSD-style license that can be
3*1a96fba6SXin Li // found in the LICENSE file.
4*1a96fba6SXin Li //
5*1a96fba6SXin Li // This header provides Address Sanitizer specific macros.
6*1a96fba6SXin Li //
7*1a96fba6SXin Li #ifndef LIBBRILLO_BRILLO_ASAN_H_
8*1a96fba6SXin Li #define LIBBRILLO_BRILLO_ASAN_H_
9*1a96fba6SXin Li 
10*1a96fba6SXin Li #if defined(__has_feature) && __has_feature(address_sanitizer)
11*1a96fba6SXin Li // ASan is enabled.
12*1a96fba6SXin Li #define BRILLO_ASAN_BUILD 1
13*1a96fba6SXin Li // Provide BRILLO_DISABLE_ASAN hook to disable ASan.
14*1a96fba6SXin Li // Put this in front on functions or global variables where required.
15*1a96fba6SXin Li #define BRILLO_DISABLE_ASAN __attribute__((no_sanitize("address")))
16*1a96fba6SXin Li #else
17*1a96fba6SXin Li #define BRILLO_DISABLE_ASAN
18*1a96fba6SXin Li #endif
19*1a96fba6SXin Li 
20*1a96fba6SXin Li #endif  // LIBBRILLO_BRILLO_ASAN_H_
21