Changeset View
Changeset View
Standalone View
Standalone View
lib/asan/asan_malloc_local.h
Show All 11 Lines | |||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef ASAN_MALLOC_LOCAL_H | #ifndef ASAN_MALLOC_LOCAL_H | ||||
#define ASAN_MALLOC_LOCAL_H | #define ASAN_MALLOC_LOCAL_H | ||||
#include "sanitizer_common/sanitizer_platform.h" | #include "sanitizer_common/sanitizer_platform.h" | ||||
#include "asan_internal.h" | #include "asan_internal.h" | ||||
// On RTEMS, we use the local pool to handle memory allocation when the ASan | |||||
// run-time is not up. | |||||
static INLINE bool EarlyMalloc() { | static INLINE bool EarlyMalloc() { | ||||
return SANITIZER_RTEMS && (!__asan::asan_inited || | return SANITIZER_RTEMS && | ||||
__asan::asan_init_is_running); | (!__asan::asan_inited || __asan::asan_init_is_running); | ||||
} | } | ||||
void* MemalignFromLocalPool(uptr alignment, uptr size); | |||||
#if SANITIZER_RTEMS | #if SANITIZER_RTEMS | ||||
bool IsFromLocalPool(const void *ptr); | bool IsFromLocalPool(const void *ptr); | ||||
void *MemalignFromLocalPool(uptr alignment, uptr size); | |||||
// On RTEMS, we use the local pool to handle memory allocation when the ASan | |||||
// run-time is not up. This macro is expanded in the context of the operator new | |||||
// implementation. | |||||
#define MAYBE_ALLOCATE_FROM_LOCAL_POOL(nothrow) \ | |||||
do { \ | |||||
if (UNLIKELY(EarlyMalloc())) { \ | |||||
void *res = MemalignFromLocalPool(SHADOW_GRANULARITY, size); \ | |||||
if (!nothrow) \ | |||||
CHECK(res); \ | |||||
return res; \ | |||||
} \ | |||||
} while (0) | |||||
#define ALLOCATE_FROM_LOCAL_POOL UNLIKELY(EarlyMalloc()) | |||||
#define IS_FROM_LOCAL_POOL(ptr) UNLIKELY(IsFromLocalPool(ptr)) | #define IS_FROM_LOCAL_POOL(ptr) UNLIKELY(IsFromLocalPool(ptr)) | ||||
#else // SANITIZER_RTEMS | #else // SANITIZER_RTEMS | ||||
#define ALLOCATE_FROM_LOCAL_POOL 0 | #define MAYBE_ALLOCATE_FROM_LOCAL_POOL(nothrow) | ||||
#define IS_FROM_LOCAL_POOL(ptr) 0 | #define IS_FROM_LOCAL_POOL(ptr) 0 | ||||
#endif // SANITIZER_RTEMS | #endif // SANITIZER_RTEMS | ||||
#endif // ASAN_MALLOC_LOCAL_H | #endif // ASAN_MALLOC_LOCAL_H |