| 1 | // -*- C++ -*-cxx . . $ `<file>/vendor/Heap-Layers/heaps/general/kingsleyheap.h`/ |
| 2 | |
| 3 | /* |
| 4 | |
| 5 | Heap Layers: An Extensible Memory Allocation Infrastructure |
| 6 | |
| 7 | Copyright (C) 2000-2020 by Emery Berger |
| 8 | http://www.emeryberger.com |
| 9 | [email protected] |
| 10 | |
| 11 | Heap Layers is distributed under the terms of the Apache 2.0 license. |
| 12 | |
| 13 | You may obtain a copy of the License at |
| 14 | http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | |
| 16 | */ |
| 17 | |
| 18 | #ifndef HL_KINGSLEYHEAP_H |
| 19 | #define HL_KINGSLEYHEAP_Hcxx . . $ `vendor/Heap-Layers/heaps/general/kingsleyheap.h:19:9`! |
| 20 | |
| 21 | #include "utility/ilog2.h"cxx . . $ `<file>/vendor/Heap-Layers/utility/ilog2.h`/ |
| 22 | #include "heaps/combining/strictsegheap.h"cxx . . $ `<file>/vendor/Heap-Layers/heaps/combining/strictsegheap.h`/ |
| 23 | |
| 24 | /** |
| 25 | * @file kingsleyheap.h |
| 26 | * @brief Classes to implement a Kingsley (power-of-two, segregated fits) allocator. |
| 27 | */ |
| 28 | |
| 29 | /** |
| 30 | * @namespace Kingsley |
| 31 | * @brief Functions to implement KingsleyHeap. |
| 32 | */ |
| 33 | |
| 34 | namespace Kingsleycxx . . $ Kingsley/ { |
| 35 | |
| 36 | inline size_t class2Sizecxx . . $ Kingsley/class2Size(c104ebd7d68b2193). (const int i) { |
| 37 | auto sz = (size_t) (1ULL << (i+3)); |
| 38 | return sz; |
| 39 | } |
| 40 | |
| 41 | inline int size2Classcxx . . $ Kingsley/size2Class(15f694ef3c96d230). (const size_t sz) { |
| 42 | auto cl = (int) HLcxx . . $ HL/::ilog2cxx . . $ HL/ilog2(ea88b852781e8a38). ((sz < 8) ? 8 : sz) - 3; |
| 43 | return cl; |
| 44 | } |
| 45 | |
| 46 | enumcxx . . $ Kingsley/$anonymous_type_9d952b818e6441f9_0# { NUMBINScxx . . $ Kingsley/NUMBINS. = 29 }; |
| 47 | |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * @class KingsleyHeap |
| 52 | * @brief The Kingsley-style allocator. |
| 53 | * @param PerClassHeap The heap to use for each size class. |
| 54 | * @param BigHeap The heap for "large" objects. |
| 55 | * @see Kingsley |
| 56 | */ |
| 57 | |
| 58 | namespace HLcxx . . $ HL/ { |
| 59 | |
| 60 | template <class PerClassHeap, class BigHeap> |
| 61 | class KingsleyHeapcxx . . $ HL/KingsleyHeap# : |
| 62 | public StrictSegHeapcxx . . $ HL/StrictSegHeap#<Kingsleycxx . . $ Kingsley/::NUMBINScxx . . $ Kingsley/NUMBINS., |
| 63 | Kingsleycxx . . $ Kingsley/::size2Classcxx . . $ Kingsley/size2Class(15f694ef3c96d230)., |
| 64 | Kingsleycxx . . $ Kingsley/::class2Sizecxx . . $ Kingsley/class2Size(c104ebd7d68b2193)., |
| 65 | PerClassHeap, |
| 66 | BigHeap> {}; |
| 67 | |
| 68 | } |
| 69 | |
| 70 | #endif |