sanitizer_allocator_internal.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #ifndef SANITIZER_ALLOCATOR_INTERNAL_H
  13. #define SANITIZER_ALLOCATOR_INTERNAL_H
  14. #include "sanitizer_allocator.h"
  15. #include "sanitizer_internal_defs.h"
  16. namespace __sanitizer {
  17. // FIXME: Check if we may use even more compact size class map for internal
  18. // purposes.
  19. typedef CompactSizeClassMap InternalSizeClassMap;
  20. struct AP32 {
  21. static const uptr kSpaceBeg = 0;
  22. static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
  23. static const uptr kMetadataSize = 0;
  24. typedef InternalSizeClassMap SizeClassMap;
  25. static const uptr kRegionSizeLog = 20;
  26. using AddressSpaceView = LocalAddressSpaceView;
  27. typedef NoOpMapUnmapCallback MapUnmapCallback;
  28. static const uptr kFlags = 0;
  29. };
  30. typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator;
  31. typedef CombinedAllocator<PrimaryInternalAllocator,
  32. LargeMmapAllocatorPtrArrayStatic>
  33. InternalAllocator;
  34. typedef InternalAllocator::AllocatorCache InternalAllocatorCache;
  35. void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr,
  36. uptr alignment = 0);
  37. void *InternalRealloc(void *p, uptr size,
  38. InternalAllocatorCache *cache = nullptr);
  39. void *InternalReallocArray(void *p, uptr count, uptr size,
  40. InternalAllocatorCache *cache = nullptr);
  41. void *InternalCalloc(uptr count, uptr size,
  42. InternalAllocatorCache *cache = nullptr);
  43. void InternalFree(void *p, InternalAllocatorCache *cache = nullptr);
  44. void InternalAllocatorLock();
  45. void InternalAllocatorUnlock();
  46. InternalAllocator *internal_allocator();
  47. } // namespace __sanitizer
  48. #endif // SANITIZER_ALLOCATOR_INTERNAL_H