39#ifndef _RTEMS_SCORE_HEAP_H
40#define _RTEMS_SCORE_HEAP_H
42#include <rtems/score/cpu.h>
50 #define HEAP_PROTECTION
214#ifndef HEAP_PROTECTION
215 #define HEAP_PROTECTION_HEADER_SIZE 0
217 #define HEAP_PROTECTOR_COUNT 2
219 #define HEAP_BEGIN_PROTECTOR_0 ((uintptr_t) 0xfd75a98f)
220 #define HEAP_BEGIN_PROTECTOR_1 ((uintptr_t) 0xbfa1f177)
221 #define HEAP_END_PROTECTOR_0 ((uintptr_t) 0xd6b8855e)
222 #define HEAP_END_PROTECTOR_1 ((uintptr_t) 0x13a44a5b)
224 #define HEAP_FREE_PATTERN ((uintptr_t) 0xe7093cdf)
226 #define HEAP_PROTECTION_OBOLUS ((Heap_Block *) 1)
228 typedef void (*_Heap_Protection_handler)(
233 typedef void (*_Heap_Protection_error_handler)(
240 _Heap_Protection_handler block_initialize;
241 _Heap_Protection_handler block_check;
242 _Heap_Protection_error_handler block_error;
246 uintptr_t delayed_free_block_count;
247 uintptr_t delayed_free_fraction;
253 uintptr_t protector [HEAP_PROTECTOR_COUNT];
257 } Heap_Protection_block_begin;
260 uintptr_t protector [HEAP_PROTECTOR_COUNT];
261 } Heap_Protection_block_end;
263 #define HEAP_PROTECTION_HEADER_SIZE \
264 (sizeof(Heap_Protection_block_begin) + sizeof(Heap_Protection_block_end))
271#define HEAP_BLOCK_HEADER_SIZE \
272 (2 * sizeof(uintptr_t) + HEAP_PROTECTION_HEADER_SIZE)
293 #ifdef HEAP_PROTECTION
294 Heap_Protection_block_begin Protection_begin;
312 #ifdef HEAP_PROTECTION
313 Heap_Protection_block_end Protection_end;
342 uintptr_t min_block_size;
343 uintptr_t area_begin;
348 #ifdef HEAP_PROTECTION
349 Heap_Protection Protection;
377 uintptr_t page_size_or_unused
434static inline uintptr_t _Heap_Align_up(
439 uintptr_t remainder = value % alignment;
441 if ( remainder != 0 ) {
442 return value - remainder + alignment;
455static inline uintptr_t _Heap_Min_block_size( uintptr_t page_size )
457 return _Heap_Align_up(
sizeof(
Heap_Block ), page_size );
467static inline uintptr_t _Heap_Area_overhead(
471 if ( page_size != 0 ) {
472 page_size = _Heap_Align_up( page_size, CPU_ALIGNMENT );
474 page_size = CPU_ALIGNMENT;
482 return page_size - 1 + _Heap_Min_block_size( page_size ) +
496static inline uintptr_t _Heap_Size_with_overhead(
502 if ( page_size != 0 ) {
503 page_size = _Heap_Align_up( page_size, CPU_ALIGNMENT );
505 page_size = CPU_ALIGNMENT;
508 if ( page_size < alignment ) {
509 page_size = alignment;
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.
#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:271
uintptr_t _Heap_Extend(Heap_Control *heap, void *area_begin, uintptr_t area_size, uintptr_t unused)
Extends the memory available for the heap.
Definition: heapextend.c:139
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:373
Heap_Error_reason
The heap error reason.
Definition: heap.h:163
@ HEAP_ERROR_BAD_USED_BLOCK
The next block of a supposed to be used block does not indicate that the block is used.
Definition: heap.h:184
@ HEAP_ERROR_BROKEN_PROTECTOR
There is an unexpected value in the heap block protector area.
Definition: heap.h:167
@ HEAP_ERROR_DOUBLE_FREE
There is was an attempt to free the same block twice.
Definition: heap.h:178
@ HEAP_ERROR_BAD_FREE_BLOCK
A supposed to be free block is not inside the heap memory area.
Definition: heap.h:189
@ HEAP_ERROR_FREE_PATTERN
There is an unexpected value in the free pattern of a free heap block.
Definition: heap.h:173
This header file provides interfaces of the Barrier Handler which are used by the implementation and ...
Heap area structure for table based heap initialization and extension.
Definition: heap.h:359
Description for free or used blocks.
Definition: heap.h:277
Heap_Block * prev
Pointer to the previous free block or part of the allocated area.
Definition: heap.h:333
uintptr_t prev_size
Size of the previous block or part of the allocated area of the previous block.
Definition: heap.h:291
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:310
Heap_Block * next
Pointer to the next free block or part of the allocated area.
Definition: heap.h:325
Control block used to manage a heap.
Definition: heap.h:339
Context of a heap error.
Definition: heap.h:197
Heap_Error_reason reason
The heap error reason.
Definition: heap.h:211
Heap_Block * block
The heap block causing the error.
Definition: heap.h:206
Heap_Control * heap
The heap of the block.
Definition: heap.h:201
Run-time heap statistics.
Definition: heapinfo.h:60
Definition: intercom.c:71
unsigned size
Definition: tte.h:1