diff options
Diffstat (limited to 'lib/scudo/scudo_allocator.h')
| -rw-r--r-- | lib/scudo/scudo_allocator.h | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/scudo/scudo_allocator.h b/lib/scudo/scudo_allocator.h index a561247def9c8..0002b4a44b781 100644 --- a/lib/scudo/scudo_allocator.h +++ b/lib/scudo/scudo_allocator.h @@ -59,9 +59,17 @@ const uptr MaxAlignmentLog = 24; // 16 MB const uptr MinAlignment = 1 << MinAlignmentLog; const uptr MaxAlignment = 1 << MaxAlignmentLog; -const uptr ChunkHeaderSize = sizeof(PackedHeader); -const uptr AlignedChunkHeaderSize = - (ChunkHeaderSize + MinAlignment - 1) & ~(MinAlignment - 1); +// constexpr version of __sanitizer::RoundUp without the extraneous CHECK. +// This way we can use it in constexpr variables and functions declarations. +constexpr uptr RoundUpTo(uptr Size, uptr Boundary) { + return (Size + Boundary - 1) & ~(Boundary - 1); +} + +namespace Chunk { + constexpr uptr getHeaderSize() { + return RoundUpTo(sizeof(PackedHeader), MinAlignment); + } +} #if SANITIZER_CAN_USE_ALLOCATOR64 const uptr AllocatorSpace = ~0ULL; @@ -74,7 +82,7 @@ struct AP64 { static const uptr kFlags = SizeClassAllocator64FlagMasks::kRandomShuffleChunks; }; -typedef SizeClassAllocator64<AP64> PrimaryAllocator; +typedef SizeClassAllocator64<AP64> PrimaryT; #else static const uptr NumRegions = SANITIZER_MMAP_RANGE_SIZE >> RegionSizeLog; # if SANITIZER_WORDSIZE == 32 @@ -94,30 +102,22 @@ struct AP32 { SizeClassAllocator32FlagMasks::kRandomShuffleChunks | SizeClassAllocator32FlagMasks::kUseSeparateSizeClassForBatch; }; -typedef SizeClassAllocator32<AP32> PrimaryAllocator; +typedef SizeClassAllocator32<AP32> PrimaryT; #endif // SANITIZER_CAN_USE_ALLOCATOR64 -// __sanitizer::RoundUp has a CHECK that is extraneous for us. Use our own. -INLINE uptr RoundUpTo(uptr Size, uptr Boundary) { - return (Size + Boundary - 1) & ~(Boundary - 1); -} - #include "scudo_allocator_secondary.h" #include "scudo_allocator_combined.h" -typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache; -typedef ScudoLargeMmapAllocator SecondaryAllocator; -typedef ScudoCombinedAllocator<PrimaryAllocator, AllocatorCache, - SecondaryAllocator> ScudoBackendAllocator; +typedef SizeClassAllocatorLocalCache<PrimaryT> AllocatorCacheT; +typedef LargeMmapAllocator SecondaryT; +typedef CombinedAllocator<PrimaryT, AllocatorCacheT, SecondaryT> BackendT; void initScudo(); -void *scudoMalloc(uptr Size, AllocType Type); -void scudoFree(void *Ptr, AllocType Type); -void scudoSizedFree(void *Ptr, uptr Size, AllocType Type); +void *scudoAllocate(uptr Size, uptr Alignment, AllocType Type); +void scudoDeallocate(void *Ptr, uptr Size, uptr Alignment, AllocType Type); void *scudoRealloc(void *Ptr, uptr Size); void *scudoCalloc(uptr NMemB, uptr Size); -void *scudoMemalign(uptr Alignment, uptr Size); void *scudoValloc(uptr Size); void *scudoPvalloc(uptr Size); int scudoPosixMemalign(void **MemPtr, uptr Alignment, uptr Size); |
