RTEMS 6.1-rc4
Loading...
Searching...
No Matches
malloc.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
14/*
15 * COPYRIGHT (c) 1989-2011.
16 * On-Line Applications Research Corporation (OAR).
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#ifndef _RTEMS_MALLOC_H
41#define _RTEMS_MALLOC_H
42
43#include <rtems.h>
44#include <rtems/bspIo.h>
45#include <rtems/libcsupport.h> /* for malloc_walk() */
46
47#include <stdint.h>
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
70
71void _Malloc_Initialize( void );
72
73typedef void *(*rtems_heap_extend_handler)(
74 Heap_Control *heap,
75 size_t alloc_size
76);
77
82 Heap_Control *heap,
83 size_t alloc_size
84);
85
86void *rtems_heap_null_extend(
87 Heap_Control *heap,
88 size_t alloc_size
89);
90
91extern const rtems_heap_extend_handler rtems_malloc_extend_handler;
92
93/*
94 * Malloc Plugin to Dirty Memory at Allocation Time
95 */
96typedef void (*rtems_malloc_dirtier_t)(void *, size_t);
97extern rtems_malloc_dirtier_t rtems_malloc_dirty_helper;
98
112void rtems_heap_set_sbrk_amount( ptrdiff_t sbrk_amount );
113
123 Heap_Control *heap,
124 size_t alloc_size
125);
126
135 void *start,
136 size_t size
137);
138
155 void **pointer,
156 size_t alignment,
157 size_t size
158);
159
181 size_t size,
182 uintptr_t alignment,
183 uintptr_t boundary
185 RTEMS_WARN_UNUSED_RESULT;
186
198void *rtems_malloc(size_t size)
199 RTEMS_MALLOCLIKE RTEMS_ALLOC_SIZE(1) RTEMS_WARN_UNUSED_RESULT;
200
217void *rtems_calloc(size_t nelem, size_t elsize)
218 RTEMS_MALLOCLIKE RTEMS_ALLOC_SIZE_2(1, 2) RTEMS_WARN_UNUSED_RESULT;
219
234 void *area_begin,
235 uintptr_t area_size
236);
237
248 const uintptr_t *block_sizes,
249 size_t block_count
250);
251
262 uintptr_t *allocatable_size
263);
264
272void rtems_heap_greedy_free( void *opaque );
273
276#ifdef __cplusplus
277}
278#endif
279
280#endif
This header file provides the kernel character input/output support API.
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:52
Heap_Control * RTEMS_Malloc_Heap
C program heap control.
Definition: mallocheap.c:45
#define RTEMS_ALLOC_ALIGN(_index)
Tells the compiler in a declaration that the memory allocation alignment parameter of this function i...
Definition: basedefs.h:193
#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:209
#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:230
#define RTEMS_MALLOCLIKE
Tells the compiler in a declaration that this function is a memory allocation function similar to mal...
Definition: basedefs.h:648
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
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_malloc_dirty_memory(void *start, size_t size)
Dirty Memory Function.
Definition: malloc_dirtier.c:47
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:43
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.
int rtems_memalign(void **pointer, size_t alignment, size_t size)
RTEMS Variation on Aligned Memory Allocation.
void rtems_heap_greedy_free(void *opaque)
Frees space of a greedy allocation.
Definition: rtems_heap_greedy.c:79
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:60
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...
void rtems_heap_sbrk_greedy_allocate(Heap_Control *heap, size_t alloc_size)
Greedy allocate that empties the sbrk memory.
Definition: rtems_heap_sbrk_greedy.c:48
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.
Standard C Library Support.
This header file defines the RTEMS Classic API.
Control block used to manage a heap.
Definition: heap.h:339
Definition: bootldr.h:42