| 1 |
//===-- sanitizer_allocator_internal.h --------------------------*- C++ -*-===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
// |
| 9 |
// This allocator is used inside run-times. |
| 10 |
// |
| 11 |
//===----------------------------------------------------------------------===// |
| 12 |
|
| 13 |
#ifndef SANITIZER_ALLOCATOR_INTERNAL_H |
| 14 |
#define SANITIZER_ALLOCATOR_INTERNAL_H |
| 15 |
|
| 16 |
#include "sanitizer_allocator.h" |
| 17 |
#include "sanitizer_internal_defs.h" |
| 18 |
|
| 19 |
namespace __sanitizer { |
| 20 |
|
| 21 |
// FIXME: Check if we may use even more compact size class map for internal |
| 22 |
// purposes. |
| 23 |
typedef CompactSizeClassMap InternalSizeClassMap; |
| 24 |
|
| 25 |
struct AP32 { |
| 26 |
static const uptr kSpaceBeg = 0; |
| 27 |
static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; |
| 28 |
static const uptr kMetadataSize = 0; |
| 29 |
typedef InternalSizeClassMap SizeClassMap; |
| 30 |
static const uptr kRegionSizeLog = 20; |
| 31 |
using AddressSpaceView = LocalAddressSpaceView; |
| 32 |
typedef NoOpMapUnmapCallback MapUnmapCallback; |
| 33 |
static const uptr kFlags = 0; |
| 34 |
}; |
| 35 |
typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator; |
| 36 |
|
| 37 |
typedef CombinedAllocator<PrimaryInternalAllocator, |
| 38 |
LargeMmapAllocatorPtrArrayStatic> |
| 39 |
InternalAllocator; |
| 40 |
typedef InternalAllocator::AllocatorCache InternalAllocatorCache; |
| 41 |
|
| 42 |
void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr, |
| 43 |
uptr alignment = 0); |
| 44 |
void *InternalRealloc(void *p, uptr size, |
| 45 |
InternalAllocatorCache *cache = nullptr); |
| 46 |
void *InternalReallocArray(void *p, uptr count, uptr size, |
| 47 |
InternalAllocatorCache *cache = nullptr); |
| 48 |
void *InternalCalloc(uptr count, uptr size, |
| 49 |
InternalAllocatorCache *cache = nullptr); |
| 50 |
void InternalFree(void *p, InternalAllocatorCache *cache = nullptr); |
| 51 |
void InternalAllocatorLock(); |
| 52 |
void InternalAllocatorUnlock(); |
| 53 |
InternalAllocator *internal_allocator(); |
| 54 |
} // namespace __sanitizer |
| 55 |
|
| 56 |
#endif // SANITIZER_ALLOCATOR_INTERNAL_H |