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