1296417Sdim//===-- sanitizer_allocator_internal.h --------------------------*- C++ -*-===// 2274201Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6274201Sdim// 7274201Sdim//===----------------------------------------------------------------------===// 8274201Sdim// 9274201Sdim// This allocator is used inside run-times. 10274201Sdim// 11274201Sdim//===----------------------------------------------------------------------===// 12274201Sdim 13274201Sdim#ifndef SANITIZER_ALLOCATOR_INTERNAL_H 14274201Sdim#define SANITIZER_ALLOCATOR_INTERNAL_H 15274201Sdim 16274201Sdim#include "sanitizer_allocator.h" 17274201Sdim#include "sanitizer_internal_defs.h" 18274201Sdim 19274201Sdimnamespace __sanitizer { 20274201Sdim 21274201Sdim// FIXME: Check if we may use even more compact size class map for internal 22274201Sdim// purposes. 23274201Sdimtypedef CompactSizeClassMap InternalSizeClassMap; 24274201Sdim 25321369Sdimstruct AP32 { 26321369Sdim static const uptr kSpaceBeg = 0; 27321369Sdim static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; 28321369Sdim static const uptr kMetadataSize = 0; 29321369Sdim typedef InternalSizeClassMap SizeClassMap; 30353358Sdim static const uptr kRegionSizeLog = 20; 31344779Sdim using AddressSpaceView = LocalAddressSpaceView; 32321369Sdim typedef NoOpMapUnmapCallback MapUnmapCallback; 33321369Sdim static const uptr kFlags = 0; 34321369Sdim}; 35321369Sdimtypedef SizeClassAllocator32<AP32> PrimaryInternalAllocator; 36274201Sdim 37353358Sdimtypedef CombinedAllocator<PrimaryInternalAllocator, 38353358Sdim LargeMmapAllocatorPtrArrayStatic> 39353358Sdim InternalAllocator; 40353358Sdimtypedef InternalAllocator::AllocatorCache InternalAllocatorCache; 41274201Sdim 42309124Sdimvoid *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr, 43309124Sdim uptr alignment = 0); 44309124Sdimvoid *InternalRealloc(void *p, uptr size, 45309124Sdim InternalAllocatorCache *cache = nullptr); 46353358Sdimvoid *InternalReallocArray(void *p, uptr count, uptr size, 47353358Sdim InternalAllocatorCache *cache = nullptr); 48353358Sdimvoid *InternalCalloc(uptr count, uptr size, 49309124Sdim InternalAllocatorCache *cache = nullptr); 50296417Sdimvoid InternalFree(void *p, InternalAllocatorCache *cache = nullptr); 51274201SdimInternalAllocator *internal_allocator(); 52274201Sdim 53296417Sdim} // namespace __sanitizer 54274201Sdim 55296417Sdim#endif // SANITIZER_ALLOCATOR_INTERNAL_H 56