1 //===-- asan_malloc_local.h -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of AddressSanitizer, an address sanity checker.
12 // Provide interfaces to check for and handle local pool memory allocation.
13 //===----------------------------------------------------------------------===//
15 #ifndef ASAN_MALLOC_LOCAL_H
16 #define ASAN_MALLOC_LOCAL_H
18 #include "sanitizer_common/sanitizer_platform.h"
19 #include "asan_internal.h"
21 // On RTEMS, we use the local pool to handle memory allocation when the ASan
22 // run-time is not up.
23 static INLINE bool EarlyMalloc() {
24 return SANITIZER_RTEMS && (!__asan::asan_inited ||
25 __asan::asan_init_is_running);
28 void* MemalignFromLocalPool(uptr alignment, uptr size);
32 bool IsFromLocalPool(const void *ptr);
34 #define ALLOCATE_FROM_LOCAL_POOL UNLIKELY(EarlyMalloc())
35 #define IS_FROM_LOCAL_POOL(ptr) UNLIKELY(IsFromLocalPool(ptr))
37 #else // SANITIZER_RTEMS
39 #define ALLOCATE_FROM_LOCAL_POOL 0
40 #define IS_FROM_LOCAL_POOL(ptr) 0
42 #endif // SANITIZER_RTEMS
44 #endif // ASAN_MALLOC_LOCAL_H