|
| 1 | +//===-- allocator_config.def ------------------------------------*- 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 file defines all the flags and types supported in Scudo. |
| 10 | + |
| 11 | +#ifndef BASE_REQUIRED_TEMPLATE_TYPE |
| 12 | +#define BASE_REQUIRED_TEMPLATE_TYPE(...) |
| 13 | +#endif |
| 14 | +#ifndef BASE_OPTIONAL |
| 15 | +#define BASE_OPTIONAL(...) |
| 16 | +#endif |
| 17 | +#ifndef PRIMARY_REQUIRED_TYPE |
| 18 | +#define PRIMARY_REQUIRED_TYPE(...) |
| 19 | +#endif |
| 20 | +#ifndef PRIMARY_REQUIRED |
| 21 | +#define PRIMARY_REQUIRED(...) |
| 22 | +#endif |
| 23 | +#ifndef PRIMARY_OPTIONAL |
| 24 | +#define PRIMARY_OPTIONAL(...) |
| 25 | +#endif |
| 26 | +#ifndef PRIMARY_OPTIONAL_TYPE |
| 27 | +#define PRIMARY_OPTIONAL_TYPE(...) |
| 28 | +#endif |
| 29 | +#ifndef SECONDARY_REQUIRED_TEMPLATE_TYPE |
| 30 | +#define SECONDARY_REQUIRED_TEMPLATE_TYPE(...) |
| 31 | +#endif |
| 32 | +#ifndef SECONDARY_CACHE_OPTIONAL |
| 33 | +#define SECONDARY_CACHE_OPTIONAL(...) |
| 34 | +#endif |
| 35 | + |
| 36 | +// BASE_REQUIRED_TEMPLATE_TYPE(NAME) |
| 37 | +// |
| 38 | +// Thread-Specific Data Registry used, shared or exclusive. |
| 39 | +BASE_REQUIRED_TEMPLATE_TYPE(TSDRegistryT) |
| 40 | + |
| 41 | +// Defines the type of Primary allocator to use. |
| 42 | +BASE_REQUIRED_TEMPLATE_TYPE(PrimaryT) |
| 43 | + |
| 44 | +// Defines the type of Secondary allocator to use. |
| 45 | +BASE_REQUIRED_TEMPLATE_TYPE(SecondaryT) |
| 46 | + |
| 47 | +// BASE_OPTIONAL(TYPE, NAME, DEFAULT) |
| 48 | +// |
| 49 | +// Indicates possible support for Memory Tagging. |
| 50 | +BASE_OPTIONAL(const bool, MaySupportMemoryTagging, false) |
| 51 | + |
| 52 | +// PRIMARY_REQUIRED_TYPE(NAME) |
| 53 | +// |
| 54 | +// SizeClassMap to use with the Primary. |
| 55 | +PRIMARY_REQUIRED_TYPE(SizeClassMap) |
| 56 | + |
| 57 | +// Defines the type and scale of a compact pointer. A compact pointer can |
| 58 | +// be understood as the offset of a pointer within the region it belongs |
| 59 | +// to, in increments of a power-of-2 scale. See `CompactPtrScale` also. |
| 60 | +PRIMARY_REQUIRED_TYPE(CompactPtrT) |
| 61 | + |
| 62 | +// PRIMARY_REQUIRED(TYPE, NAME) |
| 63 | +// |
| 64 | +// The scale of a compact pointer. E.g., Ptr = Base + (CompactPtr << Scale). |
| 65 | +PRIMARY_REQUIRED(const uptr, CompactPtrScale) |
| 66 | + |
| 67 | +// Log2 of the size of a size class region, as used by the Primary. |
| 68 | +PRIMARY_REQUIRED(const uptr, RegionSizeLog) |
| 69 | + |
| 70 | +// Log2 of the size of block group, as used by the Primary. Each group |
| 71 | +// contains a range of memory addresses, blocks in the range will belong |
| 72 | +// to the same group. In general, single region may have 1 or 2MB group |
| 73 | +// size. Multiple regions will have the group size equal to the region |
| 74 | +// size because the region size is usually smaller than 1 MB. |
| 75 | +// Smaller value gives fine-grained control of memory usage but the |
| 76 | +// trade-off is that it may take longer time of deallocation. |
| 77 | +PRIMARY_REQUIRED(const uptr, GroupSizeLog) |
| 78 | + |
| 79 | +// Call map for user memory with at least this size. Only used with primary64. |
| 80 | +PRIMARY_REQUIRED(const uptr, MapSizeIncrement) |
| 81 | + |
| 82 | +// Defines the minimal & maximal release interval that can be set. |
| 83 | +PRIMARY_REQUIRED(const s32, MinReleaseToOsIntervalMs) |
| 84 | +PRIMARY_REQUIRED(const s32, MaxReleaseToOsIntervalMs) |
| 85 | + |
| 86 | +// PRIMARY_OPTIONAL(TYPE, NAME, DEFAULT) |
| 87 | +// |
| 88 | +// Indicates support for offsetting the start of a region by a random number of |
| 89 | +// pages. Only used with primary64. |
| 90 | +PRIMARY_OPTIONAL(const bool, EnableRandomOffset, false) |
| 91 | + |
| 92 | +// PRIMARY_OPTIONAL_TYPE(NAME, DEFAULT) |
| 93 | +// |
| 94 | +// Use condition variable to shorten the waiting time of refillment of |
| 95 | +// freelist. Note that this depends on the implementation of condition |
| 96 | +// variable on each platform and the performance may vary so that it doesn not |
| 97 | +// guarantee a performance benefit. |
| 98 | +PRIMARY_OPTIONAL_TYPE(ConditionVariableT, ConditionVariableDummy) |
| 99 | + |
| 100 | +// SECONDARY_REQUIRED_TEMPLATE_TYPE(NAME) |
| 101 | +// |
| 102 | +// Defines the type of Secondary Cache to use. |
| 103 | +SECONDARY_REQUIRED_TEMPLATE_TYPE(CacheT) |
| 104 | + |
| 105 | +// SECONDARY_CACHE_OPTIONAL(TYPE, NAME, DEFAULT) |
| 106 | +// |
| 107 | +// Defines the type of cache used by the Secondary. Some additional |
| 108 | +// configuration entries can be necessary depending on the Cache. |
| 109 | +SECONDARY_CACHE_OPTIONAL(const u32, EntriesArraySize, 0) |
| 110 | +SECONDARY_CACHE_OPTIONAL(const u32, QuarantineSize, 0) |
| 111 | +SECONDARY_CACHE_OPTIONAL(const u32, DefaultMaxEntriesCount, 0) |
| 112 | +SECONDARY_CACHE_OPTIONAL(const u32, DefaultMaxEntrySize, 0) |
| 113 | +SECONDARY_CACHE_OPTIONAL(const s32, MinReleaseToOsIntervalMs, INT32_MIN) |
| 114 | +SECONDARY_CACHE_OPTIONAL(const s32, MaxReleaseToOsIntervalMs, INT32_MAX) |
| 115 | + |
| 116 | +#undef SECONDARY_CACHE_OPTIONAL |
| 117 | +#undef SECONDARY_REQUIRED_TEMPLATE_TYPE |
| 118 | +#undef PRIMARY_OPTIONAL_TYPE |
| 119 | +#undef PRIMARY_OPTIONAL |
| 120 | +#undef PRIMARY_REQUIRED |
| 121 | +#undef PRIMARY_REQUIRED_TYPE |
| 122 | +#undef BASE_OPTIONAL |
| 123 | +#undef BASE_REQUIRED_TEMPLATE_TYPE |
0 commit comments