18 #ifndef _RTEMS_SCORE_HEAP_H 19 #define _RTEMS_SCORE_HEAP_H 21 #include <rtems/score/cpu.h> 29 #define HEAP_PROTECTION 136 #ifndef HEAP_PROTECTION 137 #define HEAP_PROTECTION_HEADER_SIZE 0 139 #define HEAP_PROTECTOR_COUNT 2 141 #define HEAP_BEGIN_PROTECTOR_0 ((uintptr_t) 0xfd75a98f) 142 #define HEAP_BEGIN_PROTECTOR_1 ((uintptr_t) 0xbfa1f177) 143 #define HEAP_END_PROTECTOR_0 ((uintptr_t) 0xd6b8855e) 144 #define HEAP_END_PROTECTOR_1 ((uintptr_t) 0x13a44a5b) 146 #define HEAP_FREE_PATTERN ((uintptr_t) 0xe7093cdf) 148 #define HEAP_PROTECTION_OBOLUS ((Heap_Block *) 1) 150 typedef void (*_Heap_Protection_handler)(
156 _Heap_Protection_handler block_initialize;
157 _Heap_Protection_handler block_check;
158 _Heap_Protection_handler block_error;
162 uintptr_t delayed_free_block_count;
163 uintptr_t delayed_free_fraction;
167 uintptr_t protector [HEAP_PROTECTOR_COUNT];
171 } Heap_Protection_block_begin;
174 uintptr_t protector [HEAP_PROTECTOR_COUNT];
175 } Heap_Protection_block_end;
177 #define HEAP_PROTECTION_HEADER_SIZE \ 178 (sizeof(Heap_Protection_block_begin) + sizeof(Heap_Protection_block_end)) 185 #define HEAP_BLOCK_HEADER_SIZE \ 186 (2 * sizeof(uintptr_t) + HEAP_PROTECTION_HEADER_SIZE) 207 #ifdef HEAP_PROTECTION 208 Heap_Protection_block_begin Protection_begin;
226 #ifdef HEAP_PROTECTION 227 Heap_Protection_block_end Protection_end;
345 uintptr_t min_block_size;
346 uintptr_t area_begin;
351 #ifdef HEAP_PROTECTION 352 Heap_Protection Protection;
409 uintptr_t page_size_or_unused
457 uintptr_t remainder = value % alignment;
459 if ( remainder != 0 ) {
460 return value - remainder + alignment;
468 return _Heap_Align_up(
sizeof(
Heap_Block ), page_size );
478 if ( page_size != 0 ) {
479 page_size = _Heap_Align_up( page_size, CPU_ALIGNMENT );
481 page_size = CPU_ALIGNMENT;
497 if ( page_size != 0 ) {
498 page_size = _Heap_Align_up( page_size, CPU_ALIGNMENT );
500 page_size = CPU_ALIGNMENT;
503 if ( page_size < alignment ) {
504 page_size = alignment;
Run-time heap statistics.
Definition: heap.h:257
uintptr_t(* Heap_Initialization_or_extend_handler)(Heap_Control *heap, void *area_begin, uintptr_t area_size, uintptr_t page_size_or_unused)
Heap initialization and extend handler type.
Definition: heap.h:405
uintptr_t size_and_flag
Contains the size of the current block and a flag which indicates if the previous block is free or us...
Definition: heap.h:224
uint64_t lifetime_freed
Lifetime number of bytes freed to this heap.
Definition: heap.h:270
uintptr_t _Heap_No_extend(Heap_Control *unused_0, void *unused_1, uintptr_t unused_2, uintptr_t unused_3)
This function returns always zero.
Definition: heapnoextend.c:29
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
uint32_t frees
Total number of successful frees.
Definition: heap.h:331
RTEMS_INLINE_ROUTINE uintptr_t _Heap_Area_overhead(uintptr_t page_size)
Returns the worst case overhead to manage a memory area.
Definition: heap.h:474
Heap area structure for table based heap initialization and extension.
Definition: heap.h:391
uint32_t allocs
Total number of successful allocations.
Definition: heap.h:321
Constants and Structures Related with the Thread Control Block.
uint64_t lifetime_allocated
Lifetime number of bytes allocated from this heap.
Definition: heap.h:263
Description for free or used blocks.
Definition: heap.h:191
uint32_t failed_allocs
Total number of failed allocations.
Definition: heap.h:326
uint32_t max_free_blocks
Maximum number of free blocks ever.
Definition: heap.h:301
#define HEAP_BLOCK_HEADER_SIZE
The block header consists of the two size fields (Heap_Block::prev_size and Heap_Block::size_and_flag...
Definition: heap.h:185
uint32_t used_blocks
Current number of used blocks.
Definition: heap.h:306
This structure defines the Thread Control Block (TCB).
Definition: thread.h:671
RTEMS_INLINE_ROUTINE uintptr_t _Heap_Size_with_overhead(uintptr_t page_size, uintptr_t size, uintptr_t alignment)
Returns the size with administration and alignment overhead for one allocation.
Definition: heap.h:491
uint32_t resizes
Total number of successful resizes.
Definition: heap.h:336
Control block used to manage a heap.
Definition: heap.h:342
uintptr_t free_size
Current free size in bytes.
Definition: heap.h:284
uintptr_t size
Size of the allocatable area in bytes.
Definition: heap.h:277
uintptr_t min_free_size
Minimum free size ever in bytes.
Definition: heap.h:291
Heap_Block * next
Pointer to the next free block or part of the allocated area.
Definition: heap.h:239
uint32_t max_search
Maximum number of blocks searched ever.
Definition: heap.h:311
uintptr_t prev_size
Size of the previous block or part of the allocated area of the previous block.
Definition: heap.h:205
uint32_t free_blocks
Current number of free blocks.
Definition: heap.h:296
uint32_t searches
Total number of searches.
Definition: heap.h:316
Heap_Block * prev
Pointer to the previous free block or part of the allocated area.
Definition: heap.h:247
uintptr_t _Heap_Extend(Heap_Control *heap, void *area_begin, uintptr_t area_size, uintptr_t unused)
Extends the memory available for the heap heap using the memory area starting at area_begin of size a...
Definition: heapextend.c:120