| 1 | // -*- C++ -*- |
| 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 | /** |
| 19 | * @file heaplayers.h |
| 20 | * @brief The master Heap Layers include file. |
| 21 | * |
| 22 | * Heap Layers is an extensible memory allocator infrastructure. For |
| 23 | * more information, read the PLDI 2001 paper "Composing |
| 24 | * High-Performance Memory Allocators", by Emery D. Berger, Benjamin |
| 25 | * G. Zorn, and Kathryn S. McKinley. |
| 26 | * (http://citeseer.ist.psu.edu/berger01composing.html) |
| 27 | */ |
| 28 | |
| 29 | #ifndef HL_HEAPLAYERS_H |
| 30 | #define HL_HEAPLAYERS_H |
| 31 | |
| 32 | #include <assert.h> |
| 33 | |
| 34 | namespace HL {} |
| 35 | |
| 36 | // Define HL_EXECUTABLE_HEAP as 1 if you want that (i.e., you're doing |
| 37 | // dynamic code generation). |
| 38 | |
| 39 | // #define HL_EXECUTABLE_HEAP 1 |
| 40 | #if !defined(HL_EXECUTABLE_HEAP) |
| 41 | #define HL_EXECUTABLE_HEAP 0 |
| 42 | #endif |
| 43 | |
| 44 | // Define HL_NAMED_HEAP as 1 to id an address range (on Linux) |
| 45 | |
| 46 | // #define HL_NAMED_HEAP 1 |
| 47 | #if !defined(HL_HEAP_NAME) |
| 48 | #define HL_HEAP_NAME "Heap Layers" |
| 49 | #endif |
| 50 | |
| 51 | #if defined(_MSC_VER) |
| 52 | |
| 53 | // Microsoft Visual Studio |
| 54 | #pragma inline_depth(255) |
| 55 | #define INLINE __forceinline |
| 56 | //#define inline __forceinline |
| 57 | #define NO_INLINE __declspec(noinline) |
| 58 | #pragma warning(disable: 4530) |
| 59 | #define MALLOC_FUNCTION |
| 60 | #define RESTRICT |
| 61 | |
| 62 | #elif defined(__GNUC__) |
| 63 | |
| 64 | // GNU C |
| 65 | |
| 66 | #define NO_INLINE __attribute__ ((noinline)) |
| 67 | #define INLINE inline |
| 68 | #define MALLOC_FUNCTION __attribute__((malloc)) |
| 69 | #define RESTRICT __restrict__ |
| 70 | |
| 71 | #else |
| 72 | |
| 73 | // All others |
| 74 | |
| 75 | #define NO_INLINE |
| 76 | #define INLINE inline |
| 77 | #define MALLOC_FUNCTION |
| 78 | #define RESTRICT |
| 79 | |
| 80 | #endif |
| 81 | |
| 82 | |
| 83 | /** |
| 84 | * @def ALLOCATION_STATS |
| 85 | * |
| 86 | * Defining ALLOCATION_STATS below as 1 enables tracking of allocation |
| 87 | * statistics in a variety of layers. You then must link in |
| 88 | * definitions of the extern variables used therein; stats.cpp |
| 89 | * contains these definitions. |
| 90 | * |
| 91 | * This should be undefined for all but experimental use. |
| 92 | * |
| 93 | */ |
| 94 | |
| 95 | #ifndef ALLOCATION_STATS |
| 96 | #define ALLOCATION_STATS 0 |
| 97 | #endif |
| 98 | |
| 99 | #ifdef _MSC_VER |
| 100 | // 4786: Disable warnings about long (> 255 chars) identifiers. |
| 101 | // 4512: Disable warnings about assignment operators. |
| 102 | #pragma warning( push ) |
| 103 | #pragma warning( disable:4786 4512 ) |
| 104 | #endif |
| 105 | |
| 106 | #if !defined(HL_USE_XXREALLOC) |
| 107 | #define HL_USE_XXREALLOC 0 |
| 108 | #endif |
| 109 | |
| 110 | #include "utility/all.h" |
| 111 | #include "heaps/all.h" |
| 112 | #include "locks/all.h" |
| 113 | #include "threads/all.h" |
| 114 | #include "wrappers/all.h" |
| 115 | |
| 116 | #ifdef _MSC_VER |
| 117 | #pragma warning( pop ) |
| 118 | #endif |
| 119 | |
| 120 | #endif // _HEAPLAYERS_H_ |