RTEMS
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 
23 #include <stdint.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
44 
45 extern ptrdiff_t RTEMS_Malloc_Sbrk_amount;
46 
47 void _Malloc_Initialize( void );
48 
49 static inline void rtems_heap_set_sbrk_amount( ptrdiff_t sbrk_amount )
50 {
51  RTEMS_Malloc_Sbrk_amount = sbrk_amount;
52 }
53 
54 typedef void *(*rtems_heap_extend_handler)(
55  Heap_Control *heap,
56  size_t alloc_size
57 );
58 
63  Heap_Control *heap,
64  size_t alloc_size
65 );
66 
67 void *rtems_heap_null_extend(
68  Heap_Control *heap,
69  size_t alloc_size
70 );
71 
72 extern const rtems_heap_extend_handler rtems_malloc_extend_handler;
73 
74 /*
75  * Malloc Plugin to Dirty Memory at Allocation Time
76  */
77 typedef void (*rtems_malloc_dirtier_t)(void *, size_t);
78 extern rtems_malloc_dirtier_t rtems_malloc_dirty_helper;
79 
88  void *start,
89  size_t size
90 );
91 
107 int rtems_memalign(
108  void **pointer,
109  size_t alignment,
110  size_t size
111 );
112 
134  size_t size,
135  uintptr_t alignment,
136  uintptr_t boundary
139 
151 void *rtems_malloc(size_t size)
153 
170 void *rtems_calloc(size_t nelem, size_t elsize)
172 
187  void *area_begin,
188  uintptr_t area_size
189 );
190 
201  const uintptr_t *block_sizes,
202  size_t block_count
203 );
204 
215  uintptr_t *allocatable_size
216 );
217 
225 void rtems_heap_greedy_free( void *opaque );
226 
227 #ifdef __cplusplus
228 }
229 #endif
230 
231 #endif
#define RTEMS_ALLOC_SIZE_2(_count_index, _size_index)
Tells the compiler in a declaration that the memory allocation item count and item size parameter of ...
Definition: basedefs.h:442
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.
void * rtems_heap_extend_via_sbrk(Heap_Control *heap, size_t alloc_size)
RTEMS Extend Heap via Sbrk.
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.
void rtems_heap_greedy_free(void *opaque)
Frees space of a greedy allocation.
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
#define RTEMS_ALLOC_ALIGN(_index)
Tells the compiler in a declaration that the memory allocation alignment parameter of this function i...
Definition: basedefs.h:406
void rtems_malloc_dirty_memory(void *start, size_t size)
Dirty Memory Function.
#define RTEMS_ALLOC_SIZE(_index)
Tells the compiler in a declaration that the memory allocation size parameter of this function is sim...
Definition: basedefs.h:422
Control block used to manage a heap.
Definition: heap.h:318
Heap_Control * RTEMS_Malloc_Heap
C program heap control.
Standard C Library Support.
This header file defines the RTEMS Classic API.
Interface to Kernel Print Methods.
void * rtems_heap_greedy_allocate(const uintptr_t *block_sizes, size_t block_count)
Greedy allocate that empties the heap.
#define RTEMS_MALLOCLIKE
Tells the compiler in a declaration that this function is a memory allocation function similar to mal...
Definition: basedefs.h:697
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...
#define RTEMS_WARN_UNUSED_RESULT
Tells the compiler in a declaration that the result of this function should be used.
Definition: basedefs.h:892
int rtems_memalign(void **pointer, size_t alignment, size_t size)
RTEMS Variation on Aligned Memory Allocation.
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.
void * rtems_heap_greedy_allocate_all_except_largest(uintptr_t *allocatable_size)
Greedy allocate all blocks except the largest free block.