]> git.ipfire.org Git - thirdparty/gcc.git/blame - libsanitizer/sanitizer_common/sanitizer_allocator_internal.h
Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856).
[thirdparty/gcc.git] / libsanitizer / sanitizer_common / sanitizer_allocator_internal.h
CommitLineData
696d846a 1//===-- sanitizer_allocator_internal.h --------------------------*- C++ -*-===//
ef1b3fda
KS
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//===----------------------------------------------------------------------===//
11
12#ifndef SANITIZER_ALLOCATOR_INTERNAL_H
13#define SANITIZER_ALLOCATOR_INTERNAL_H
14
15#include "sanitizer_allocator.h"
16#include "sanitizer_internal_defs.h"
17
18namespace __sanitizer {
19
20// FIXME: Check if we may use even more compact size class map for internal
21// purposes.
22typedef CompactSizeClassMap InternalSizeClassMap;
23
ef1b3fda 24static const uptr kInternalAllocatorRegionSizeLog = 20;
df77f0e4 25static const uptr kInternalAllocatorNumRegions =
5d3805fc
JJ
26 SANITIZER_MMAP_RANGE_SIZE >> kInternalAllocatorRegionSizeLog;
27#if SANITIZER_WORDSIZE == 32
df77f0e4 28typedef FlatByteMap<kInternalAllocatorNumRegions> ByteMap;
ef1b3fda 29#else
df77f0e4
KS
30typedef TwoLevelByteMap<(kInternalAllocatorNumRegions >> 12), 1 << 12> ByteMap;
31#endif
5d3805fc
JJ
32struct 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;
41};
42typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator;
ef1b3fda
KS
43
44typedef SizeClassAllocatorLocalCache<PrimaryInternalAllocator>
45 InternalAllocatorCache;
46
eac97531
ML
47typedef LargeMmapAllocator<NoOpMapUnmapCallback,
48 LargeMmapAllocatorPtrArrayStatic>
49 SecondaryInternalAllocator;
50
ef1b3fda 51typedef CombinedAllocator<PrimaryInternalAllocator, InternalAllocatorCache,
eac97531 52 SecondaryInternalAllocator> InternalAllocator;
ef1b3fda 53
10189819
MO
54void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr,
55 uptr alignment = 0);
56void *InternalRealloc(void *p, uptr size,
57 InternalAllocatorCache *cache = nullptr);
58void *InternalCalloc(uptr countr, uptr size,
59 InternalAllocatorCache *cache = nullptr);
696d846a 60void InternalFree(void *p, InternalAllocatorCache *cache = nullptr);
ef1b3fda
KS
61InternalAllocator *internal_allocator();
62
696d846a
MO
63} // namespace __sanitizer
64
696d846a 65#endif // SANITIZER_ALLOCATOR_INTERNAL_H