RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
rbheap.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
9 *
10 * embedded brains GmbH
11 * Obere Lagerstr. 30
12 * 82178 Puchheim
13 * Germany
14 * <rtems@embedded-brains.de>
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 */
20
21#ifndef _RTEMS_RBHEAP_H
22#define _RTEMS_RBHEAP_H
23
24#include <rtems.h>
25#include <rtems/chain.h>
26#include <rtems/rbtree.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
54typedef struct {
64
70
75 uintptr_t begin;
76
80 uintptr_t size;
82
84
106
115
123
128
132 uintptr_t alignment;
133
138
143};
144
162 void *area_begin,
163 uintptr_t area_size,
164 uintptr_t alignment,
165 rtems_rbheap_extend_descriptors extend_descriptors,
166 void *handler_arg
167);
168
183
197
198static inline rtems_chain_control *rtems_rbheap_get_spare_descriptor_chain(
200)
201{
202 return &control->spare_descriptor_chain;
203}
204
205static inline void rtems_rbheap_add_to_spare_descriptor_chain(
207 rtems_rbheap_chunk *chunk
208)
209{
210 rtems_chain_control *chain =
211 rtems_rbheap_get_spare_descriptor_chain(control);
212
215}
216
217static inline void rtems_rbheap_set_extend_descriptors(
219 rtems_rbheap_extend_descriptors extend_descriptors
220)
221{
222 control->extend_descriptors = extend_descriptors;
223}
224
225static inline void *rtems_rbheap_get_handler_arg(
227)
228{
229 return control->handler_arg;
230}
231
232static inline void rtems_rbheap_set_handler_arg(
234 void *handler_arg
235)
236{
237 control->handler_arg = handler_arg;
238}
239
244
250);
251
254/* Private API */
255
256#define rtems_rbheap_chunk_of_node(node) \
257 RTEMS_CONTAINER_OF(node, rtems_rbheap_chunk, tree_node)
258
259static inline bool rtems_rbheap_is_chunk_free(const rtems_rbheap_chunk *chunk)
260{
262}
263
264#ifdef __cplusplus
265}
266#endif
267
268#endif /* _RTEMS_RBHEAP_H */
Chain API.
RTEMS_INLINE_ROUTINE void rtems_chain_prepend_unprotected(rtems_chain_control *the_chain, rtems_chain_node *the_node)
Prepend a node (unprotected).
Definition: chain.h:714
RTEMS_INLINE_ROUTINE void rtems_chain_initialize_node(rtems_chain_node *node)
Initializes a chain node.
Definition: chain.h:198
RTEMS_INLINE_ROUTINE bool rtems_chain_is_node_off_chain(const rtems_chain_node *node)
Is the node off chain.
Definition: chain.h:216
RBTree_Control rtems_rbtree_control
Definition: rbtree.h:55
rtems_status_code
Classic API Status.
Definition: status.h:43
rtems_status_code rtems_rbheap_initialize(rtems_rbheap_control *control, void *area_begin, uintptr_t area_size, uintptr_t alignment, rtems_rbheap_extend_descriptors extend_descriptors, void *handler_arg)
Initializes the red-black tree heap control.
Definition: rbheap.c:91
rtems_status_code rtems_rbheap_free(rtems_rbheap_control *control, void *ptr)
Frees a chunk of memory ptr allocated from the red-black tree heap control.
Definition: rbheap.c:243
void rtems_rbheap_extend_descriptors_never(rtems_rbheap_control *control)
Chunk descriptor extend handler that does nothing.
Definition: rbheap.c:270
void(* rtems_rbheap_extend_descriptors)(rtems_rbheap_control *control)
Handler to extend the available chunk descriptors.
Definition: rbheap.h:105
void rtems_rbheap_extend_descriptors_with_malloc(rtems_rbheap_control *control)
Chunk descriptor extend handler that uses malloc().
Definition: rbheap.c:275
void * rtems_rbheap_allocate(rtems_rbheap_control *control, size_t size)
Allocates a chunk of memory of at least size bytes from the red-black tree heap control.
Definition: rbheap.c:165
Constants and Structures Associated with the RBTree API in RTEMS.
Definition: chain.h:68
Red-black tree node.
Definition: rbtree.h:55
Definition: intercom.c:74
Red-black heap chunk descriptor.
Definition: rbheap.h:54
uintptr_t size
Definition: rbheap.h:80
rtems_chain_node chain_node
Definition: rbheap.h:63
uintptr_t begin
Definition: rbheap.h:75
rtems_rbtree_node tree_node
Definition: rbheap.h:69
Red-black heap control.
Definition: rbheap.h:110
rtems_chain_control spare_descriptor_chain
Definition: rbheap.h:122
rtems_chain_control free_chunk_chain
Definition: rbheap.h:114
uintptr_t alignment
Definition: rbheap.h:132
rtems_rbheap_extend_descriptors extend_descriptors
Definition: rbheap.h:137
rtems_rbtree_control chunk_tree
Definition: rbheap.h:127
void * handler_arg
Definition: rbheap.h:142
unsigned size
Definition: tte.h:1
Definition: chain.h:86