Update LOCAL_PATCHES after libsanitizer merge.
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_allocator_internal.h
blob05aed0ecfe04aa44a0cef7cc024b5812a32696ac
1 //===-- sanitizer_allocator_internal.h --------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This allocator is used inside run-times.
9 //
10 //===----------------------------------------------------------------------===//
12 #ifndef SANITIZER_ALLOCATOR_INTERNAL_H
13 #define SANITIZER_ALLOCATOR_INTERNAL_H
15 #include "sanitizer_allocator.h"
16 #include "sanitizer_internal_defs.h"
18 namespace __sanitizer {
20 // FIXME: Check if we may use even more compact size class map for internal
21 // purposes.
22 typedef CompactSizeClassMap InternalSizeClassMap;
24 static const uptr kInternalAllocatorRegionSizeLog = 20;
25 static const uptr kInternalAllocatorNumRegions =
26 SANITIZER_MMAP_RANGE_SIZE >> kInternalAllocatorRegionSizeLog;
27 #if SANITIZER_WORDSIZE == 32
28 typedef FlatByteMap<kInternalAllocatorNumRegions> ByteMap;
29 #else
30 typedef TwoLevelByteMap<(kInternalAllocatorNumRegions >> 12), 1 << 12> ByteMap;
31 #endif
32 struct AP32 {
33 static const uptr kSpaceBeg = 0;
34 static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
35 static const uptr kMetadataSize = 0;
36 typedef InternalSizeClassMap SizeClassMap;
37 static const uptr kRegionSizeLog = kInternalAllocatorRegionSizeLog;
38 typedef __sanitizer::ByteMap ByteMap;
39 typedef NoOpMapUnmapCallback MapUnmapCallback;
40 static const uptr kFlags = 0;
42 typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator;
44 typedef SizeClassAllocatorLocalCache<PrimaryInternalAllocator>
45 InternalAllocatorCache;
47 typedef LargeMmapAllocator<NoOpMapUnmapCallback,
48 LargeMmapAllocatorPtrArrayStatic>
49 SecondaryInternalAllocator;
51 typedef CombinedAllocator<PrimaryInternalAllocator, InternalAllocatorCache,
52 SecondaryInternalAllocator> InternalAllocator;
54 void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr,
55 uptr alignment = 0);
56 void *InternalRealloc(void *p, uptr size,
57 InternalAllocatorCache *cache = nullptr);
58 void *InternalCalloc(uptr countr, uptr size,
59 InternalAllocatorCache *cache = nullptr);
60 void InternalFree(void *p, InternalAllocatorCache *cache = nullptr);
61 InternalAllocator *internal_allocator();
63 } // namespace __sanitizer
65 #endif // SANITIZER_ALLOCATOR_INTERNAL_H