virtmem
virtual memory library for Arduino
config.h
Go to the documentation of this file.
1 #ifndef VIRTMEM_CONFIG_H
2 #define VIRTMEM_CONFIG_H
3 
9 #include <stdint.h>
10 
11 #ifdef DOXYGEN
12 // prevent double definitions for Doxygen
13 #undef VIRTMEM_WRAP_CPOINTERS
14 #undef VIRTMEM_VIRT_ADDRESS_OPERATOR
15 #undef VIRTMEM_TRACE_STATS
16 #undef VIRTMEM_CPP11
17 #undef VIRTMEM_EXPLICIT
18 #endif
19 
25 //#define VIRTMEM_WRAP_CPOINTERS
26 
39 #define VIRTMEM_VIRT_ADDRESS_OPERATOR
40 
47 //#define VIRTMEM_TRACE_STATS
48 
55 #define VIRTMEM_DEFAULT_POOLSIZE 1024l * 1024l
56 
61 #if __cplusplus > 199711L
62 #define VIRTMEM_CPP11
63 #endif
64 
72 #define VIRTMEM_EXPLICIT explicit
73 
74 namespace virtmem {
75 
76 // Default virtual memory page settings
77 // NOTE: Take care of sufficiently large int types when increasing these values
78 
79 #if defined(__MK20DX256__) || defined(__SAM3X8E__) // Teensy 3.1 / Arduino Due (>= 64 kB sram)
80 struct DefaultAllocProperties
81 {
82  static const uint8_t smallPageCount = 4, smallPageSize = 64;
83  static const uint8_t mediumPageCount = 4;
84  static const uint16_t mediumPageSize = 256;
85  static const uint8_t bigPageCount = 4;
86  static const uint16_t bigPageSize = 1024 * 1;
87 };
88 #elif defined(__MK20DX128__) // Teensy 3.0 (16 kB sram)
89 struct DefaultAllocProperties
90 {
91  static const uint8_t smallPageCount = 4, smallPageSize = 32;
92  static const uint8_t mediumPageCount = 4, mediumPageSize = 128;
93  static const uint8_t bigPageCount = 4;
94  static const uint16_t bigPageSize = 512 * 1;
95 };
96 // Teensy LC / Arduino mega (8 kB sram)
97 #elif defined(__MKL26Z64__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
98 struct DefaultAllocProperties
99 {
100  static const uint8_t smallPageCount = 4, smallPageSize = 32;
101  static const uint8_t mediumPageCount = 4, mediumPageSize = 128;
102  static const uint8_t bigPageCount = 4;
103  static const uint16_t bigPageSize = 512 * 1;
104 };
105 // PC like platform
106 #elif defined(__unix__) || defined(__UNIX__) || (defined(__APPLE__) && defined(__MACH__)) || defined(_WIN32)
107 struct DefaultAllocProperties
108 {
109  static const uint8_t smallPageCount = 4, smallPageSize = 64;
110  static const uint8_t mediumPageCount = 4;
111  static const uint16_t mediumPageSize = 256;
112  static const uint8_t bigPageCount = 4;
113  static const uint16_t bigPageSize = 1024 * 32;
114 };
115 #else
116 // Small AVR like MCUs (e.g. Arduino Uno) or unknown platform. In the latter case these settings
117 // are considered as a safe default.
118 
119 // Not a small AVR?
120 #if !defined(__AVR_ATmega168__) && !defined(__AVR_ATmega328P__) && !defined(__AVR_ATmega32U4__)
121 #warning "Unknown platform. You probably want to change virtual memory page settings."
122 #endif
123 
125 {
126  static const uint8_t smallPageCount = 2, smallPageSize = 16;
127  static const uint8_t mediumPageCount = 1, mediumPageSize = 32;
128  static const uint8_t bigPageCount = 1, bigPageSize = 128;
129 };
130 
131 #endif
132 
192 }
193 
194 #ifdef DOXYGEN
195 // Define macros so Doxygen can generate documentation for normally undefined macros
196 #ifndef VIRTMEM_WRAP_CPOINTERS
197 #define VIRTMEM_WRAP_CPOINTERS
198 #endif
199 
200 #ifndef VIRTMEM_VIRT_ADDRESS_OPERATOR
201 #define VIRTMEM_VIRT_ADDRESS_OPERATOR
202 #endif
203 
204 #ifndef VIRTMEM_CPP11
205 #define VIRTMEM_CPP11
206 #endif
207 
208 #ifndef VIRTMEM_TRACE_STATS
209 #define VIRTMEM_TRACE_STATS
210 #endif
211 #endif
212 
213 #endif // CONFIG_H
static const uint8_t bigPageCount
The number of big pages.
Definition: config.h:128
contains all code from virtmem
Definition: base_alloc.cpp:22
static const uint8_t smallPageSize
The size of a small page.
Definition: config.h:126
static const uint8_t bigPageSize
The size of a big page.
Definition: config.h:128
static const uint8_t mediumPageSize
The size of a medium page.
Definition: config.h:127
static const uint8_t smallPageCount
The number of small pages.
Definition: config.h:126
This struct contains default parameters for virtual memory pages.
Definition: config.h:124
static const uint8_t mediumPageCount
The number of medium pages.
Definition: config.h:127