10b57cec5SDimitry Andric //===-- sanitizer_allocator_internal.h --------------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This allocator is used inside run-times. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef SANITIZER_ALLOCATOR_INTERNAL_H 140b57cec5SDimitry Andric #define SANITIZER_ALLOCATOR_INTERNAL_H 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "sanitizer_allocator.h" 170b57cec5SDimitry Andric #include "sanitizer_internal_defs.h" 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric namespace __sanitizer { 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric // FIXME: Check if we may use even more compact size class map for internal 220b57cec5SDimitry Andric // purposes. 230b57cec5SDimitry Andric typedef CompactSizeClassMap InternalSizeClassMap; 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric struct AP32 { 260b57cec5SDimitry Andric static const uptr kSpaceBeg = 0; 270b57cec5SDimitry Andric static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; 280b57cec5SDimitry Andric static const uptr kMetadataSize = 0; 290b57cec5SDimitry Andric typedef InternalSizeClassMap SizeClassMap; 300b57cec5SDimitry Andric static const uptr kRegionSizeLog = 20; 310b57cec5SDimitry Andric using AddressSpaceView = LocalAddressSpaceView; 320b57cec5SDimitry Andric typedef NoOpMapUnmapCallback MapUnmapCallback; 330b57cec5SDimitry Andric static const uptr kFlags = 0; 340b57cec5SDimitry Andric }; 350b57cec5SDimitry Andric typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator; 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric typedef CombinedAllocator<PrimaryInternalAllocator, 380b57cec5SDimitry Andric LargeMmapAllocatorPtrArrayStatic> 390b57cec5SDimitry Andric InternalAllocator; 400b57cec5SDimitry Andric typedef InternalAllocator::AllocatorCache InternalAllocatorCache; 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr, 430b57cec5SDimitry Andric uptr alignment = 0); 440b57cec5SDimitry Andric void *InternalRealloc(void *p, uptr size, 450b57cec5SDimitry Andric InternalAllocatorCache *cache = nullptr); 460b57cec5SDimitry Andric void *InternalReallocArray(void *p, uptr count, uptr size, 470b57cec5SDimitry Andric InternalAllocatorCache *cache = nullptr); 480b57cec5SDimitry Andric void *InternalCalloc(uptr count, uptr size, 490b57cec5SDimitry Andric InternalAllocatorCache *cache = nullptr); 500b57cec5SDimitry Andric void InternalFree(void *p, InternalAllocatorCache *cache = nullptr); 514824e7fdSDimitry Andric void InternalAllocatorLock(); 524824e7fdSDimitry Andric void InternalAllocatorUnlock(); 530b57cec5SDimitry Andric InternalAllocator *internal_allocator(); 540b57cec5SDimitry Andric } // namespace __sanitizer 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric #endif // SANITIZER_ALLOCATOR_INTERNAL_H 57