| 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 | #ifndef HL_MALLOCINFO_H |
| 19 | #define HL_MALLOCINFO_H |
| 20 | |
| 21 | #include <limits.h> |
| 22 | |
| 23 | namespace HL { |
| 24 | |
| 25 | class MallocInfo { |
| 26 | public: |
| 27 | // Prevent integer overflows by restricting allocation size (usually 2GB). |
| 28 | enum { MaxSize = UINT_MAX / 2 }; |
| 29 | |
| 30 | #if defined(__LP64__) || defined(_LP64) || (defined(__APPLE__) && !(defined(__i386__) || defined(__ppc__))) || defined(_WIN64) || defined(__x86_64__) |
| 31 | enum { MinSize = 16UL }; |
| 32 | enum { Alignment = 16UL }; |
| 33 | #else |
| 34 | enum { MinSize = sizeof(double) }; |
| 35 | enum { Alignment = sizeof(double) }; |
| 36 | #endif |
| 37 | }; |
| 38 | |
| 39 | } |
| 40 | |
| 41 | #endif |