RTEMS: cpukit/include/rtems/malloc.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
malloc.h
Go to the documentation of this file.
1
7/*
8 * COPYRIGHT (c) 1989-2011.
9 * On-Line Applications Research Corporation (OAR).
10 *
11 * The license and distribution terms for this file may in
12 * the file LICENSE in this distribution or at
13 * http://www.rtems.org/license/LICENSE.
14 */
15
16#ifndef _RTEMS_MALLOC_H
17#define _RTEMS_MALLOC_H
18
19#include <rtems.h>
20#include <rtems/bspIo.h>
21#include <rtems/libcsupport.h> /* for malloc_walk() */
22#include <rtems/score/memory.h>
23
24#include <stdint.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
44extern Heap_Control *RTEMS_Malloc_Heap;
45
46void RTEMS_Malloc_Initialize(
47 const Memory_Information *mem,
48 Heap_Initialization_or_extend_handler extend
49);
50
51extern ptrdiff_t RTEMS_Malloc_Sbrk_amount;
52
53static inline void rtems_heap_set_sbrk_amount( ptrdiff_t sbrk_amount )
54{
55 RTEMS_Malloc_Sbrk_amount = sbrk_amount;
56}
57
58typedef void *(*rtems_heap_extend_handler)(
59 Heap_Control *heap,
60 size_t alloc_size
61);
62
66void *rtems_heap_extend_via_sbrk(
67 Heap_Control *heap,
68 size_t alloc_size
69);
70
71void *rtems_heap_null_extend(
72 Heap_Control *heap,
73 size_t alloc_size
74);
75
76extern const rtems_heap_extend_handler rtems_malloc_extend_handler;
77
78/*
79 * Malloc Plugin to Dirty Memory at Allocation Time
80 */
81typedef void (*rtems_malloc_dirtier_t)(void *, size_t);
82extern rtems_malloc_dirtier_t rtems_malloc_dirty_helper;
83
91void rtems_malloc_dirty_memory(
92 void *start,
93 size_t size
94);
95
111 int rtems_memalign(
112 void **pointer,
113 size_t alignment,
114 size_t size
115);
116
137 void *rtems_heap_allocate_aligned_with_boundary(
138 size_t size,
139 uintptr_t alignment,
140 uintptr_t boundary
141) RTEMS_MALLOCLIKE RTEMS_ALLOC_SIZE(1) RTEMS_ALLOC_ALIGN(2)
142 RTEMS_WARN_UNUSED_RESULT;
143
155 void *rtems_malloc(size_t size)
156 RTEMS_MALLOCLIKE RTEMS_ALLOC_SIZE(1) RTEMS_WARN_UNUSED_RESULT;
157
174 void *rtems_calloc(size_t nelem, size_t elsize)
175 RTEMS_MALLOCLIKE RTEMS_ALLOC_SIZE_2(1, 2) RTEMS_WARN_UNUSED_RESULT;
176
190 rtems_status_code rtems_heap_extend(
191 void *area_begin,
192 uintptr_t area_size
193);
194
204void *rtems_heap_greedy_allocate(
205 const uintptr_t *block_sizes,
206 size_t block_count
207);
208
218void *rtems_heap_greedy_allocate_all_except_largest(
219 uintptr_t *allocatable_size
220);
221
229void rtems_heap_greedy_free( void *opaque );
230
231#ifdef __cplusplus
232}
233#endif
234
235#endif
bspIo.h
Interface to Kernel Print Methods.
rtems_status_code
rtems_status_code
Classic API Status.
Definition: status.h:43
RTEMS_ALLOC_ALIGN
#define RTEMS_ALLOC_ALIGN(_index)
Tells the compiler the memory allocation alignment parameter of this function similar to aligned_allo...
Definition: basedefs.h:290
RTEMS_ALLOC_SIZE
#define RTEMS_ALLOC_SIZE(_index)
Tells the compiler the memory allocation size parameter of this function similar to malloc().
Definition: basedefs.h:269
RTEMS_ALLOC_SIZE_2
#define RTEMS_ALLOC_SIZE_2(_count_index, _size_index)
Tells the compiler the memory allocation item count and item size parameter of this function similar ...
Definition: basedefs.h:280
RTEMS_MALLOCLIKE
#define RTEMS_MALLOCLIKE
Tells the compiler that this function is a memory allocation function similar to malloc().
Definition: basedefs.h:259
Heap_Initialization_or_extend_handler
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:352
libcsupport.h
Standard C Library Support.
rtems_heap_allocate_aligned_with_boundary
void * rtems_heap_allocate_aligned_with_boundary(size_t size, uintptr_t alignment, uintptr_t boundary) RTEMS_MALLOCLIKE RTEMS_ALLOC_SIZE(1) RTEMS_ALLOC_ALIGN(2) RTEMS_WARN_UNUSED_RESULT
Allocates a memory area of size size bytes from the heap.
rtems_malloc_dirty_memory
void rtems_malloc_dirty_memory(void *start, size_t size)
Dirty Memory Function.
Definition: malloc_dirtier.c:28
rtems_heap_greedy_allocate
void * rtems_heap_greedy_allocate(const uintptr_t *block_sizes, size_t block_count)
Greedy allocate that empties the heap.
Definition: rtems_heap_greedy.c:28
rtems_malloc
void * rtems_malloc(size_t size) RTEMS_MALLOCLIKE RTEMS_ALLOC_SIZE(1) RTEMS_WARN_UNUSED_RESULT
Allocates a memory area of the specified size from the heap.
rtems_memalign
int rtems_memalign(void **pointer, size_t alignment, size_t size)
RTEMS Variation on Aligned Memory Allocation.
rtems_heap_extend_via_sbrk
void * rtems_heap_extend_via_sbrk(Heap_Control *heap, size_t alloc_size)
RTEMS Extend Heap via Sbrk.
Definition: rtems_heap_extend_via_sbrk.c:34
RTEMS_Malloc_Heap
Heap_Control * RTEMS_Malloc_Heap
C program heap control.
Definition: malloc_initialize.c:26
rtems_heap_greedy_free
void rtems_heap_greedy_free(void *opaque)
Frees space of a greedy allocation.
Definition: rtems_heap_greedy.c:58
rtems_heap_greedy_allocate_all_except_largest
void * rtems_heap_greedy_allocate_all_except_largest(uintptr_t *allocatable_size)
Greedy allocate all blocks except the largest free block.
Definition: rtems_heap_greedy.c:42
rtems_heap_extend
rtems_status_code rtems_heap_extend(void *area_begin, uintptr_t area_size)
Extends the memory available for the heap using the memory area starting at area_begin of size area_s...
rtems_calloc
void * rtems_calloc(size_t nelem, size_t elsize) RTEMS_MALLOCLIKE RTEMS_ALLOC_SIZE_2(1
Allocates a memory area for the specified count of elements from the heap.
memory.h
Memory Handler API.
rtems.h
Heap_Control
Control block used to manage a heap.
Definition: heap.h:318
Memory_Information
The memory information.
Definition: memory.h:80
opaque
Definition: bootldr.h:42