xref: /netbsd-src/external/gpl3/gcc.old/dist/libsanitizer/asan/asan_malloc_local.h (revision 627f7eb200a4419d89b531d55fccd2ee3ffdcde0)
1 //===-- asan_malloc_local.h -------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // Provide interfaces to check for and handle local pool memory allocation.
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef ASAN_MALLOC_LOCAL_H
14 #define ASAN_MALLOC_LOCAL_H
15 
16 #include "sanitizer_common/sanitizer_platform.h"
17 #include "asan_internal.h"
18 
19 // On RTEMS, we use the local pool to handle memory allocation when the ASan
20 // run-time is not up.
EarlyMalloc()21 static INLINE bool EarlyMalloc() {
22   return SANITIZER_RTEMS && (!__asan::asan_inited ||
23                              __asan::asan_init_is_running);
24 }
25 
26 void* MemalignFromLocalPool(uptr alignment, uptr size);
27 
28 #if SANITIZER_RTEMS
29 
30 bool IsFromLocalPool(const void *ptr);
31 
32 #define ALLOCATE_FROM_LOCAL_POOL UNLIKELY(EarlyMalloc())
33 #define IS_FROM_LOCAL_POOL(ptr) UNLIKELY(IsFromLocalPool(ptr))
34 
35 #else  // SANITIZER_RTEMS
36 
37 #define ALLOCATE_FROM_LOCAL_POOL 0
38 #define IS_FROM_LOCAL_POOL(ptr) 0
39 
40 #endif  // SANITIZER_RTEMS
41 
42 #endif  // ASAN_MALLOC_LOCAL_H
43