2018-11-16 Richard Biener <rguenther@suse.de>
[official-gcc.git] / libsanitizer / asan / asan_malloc_local.h
blob354189315fb9047b6b5db1bb31005762c906f286
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 //===----------------------------------------------------------------------===//
13 #ifndef ASAN_MALLOC_LOCAL_H
14 #define ASAN_MALLOC_LOCAL_H
16 #include "sanitizer_common/sanitizer_platform.h"
17 #include "asan_internal.h"
19 // On RTEMS, we use the local pool to handle memory allocation when the ASan
20 // run-time is not up.
21 static INLINE bool EarlyMalloc() {
22 return SANITIZER_RTEMS && (!__asan::asan_inited ||
23 __asan::asan_init_is_running);
26 void* MemalignFromLocalPool(uptr alignment, uptr size);
28 #if SANITIZER_RTEMS
30 bool IsFromLocalPool(const void *ptr);
32 #define ALLOCATE_FROM_LOCAL_POOL UNLIKELY(EarlyMalloc())
33 #define IS_FROM_LOCAL_POOL(ptr) UNLIKELY(IsFromLocalPool(ptr))
35 #else // SANITIZER_RTEMS
37 #define ALLOCATE_FROM_LOCAL_POOL 0
38 #define IS_FROM_LOCAL_POOL(ptr) 0
40 #endif // SANITIZER_RTEMS
42 #endif // ASAN_MALLOC_LOCAL_H