RTEMS: cpukit/include/rtems/score/freechain.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
freechain.h
Go to the documentation of this file.
1
8/*
9 * Copyright (c) 2013 Gedare Bloom.
10 *
11 * The license and distribution terms for this file may be
12 * found in the file LICENSE in this distribution or at
13 * http://www.rtems.org/license/LICENSE.
14 */
15
16#ifndef _RTEMS_SCORE_FREECHAIN_H
17#define _RTEMS_SCORE_FREECHAIN_H
18
19#include <rtems/score/basedefs.h>
20#include <rtems/score/chainimpl.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
43 typedef void *( *Freechain_Allocator )( size_t size );
44
48 typedef struct {
52 Chain_Control Free;
53} Freechain_Control;
54
67 RTEMS_INLINE_ROUTINE void _Freechain_Initialize(
68 Freechain_Control *freechain,
69 void *initial_nodes,
70 size_t number_nodes,
71 size_t node_size
72)
73{
74 _Chain_Initialize(
75 &freechain->Free,
76 initial_nodes,
77 number_nodes,
78 node_size
79 );
80}
81
87 RTEMS_INLINE_ROUTINE bool _Freechain_Is_empty(
88 const Freechain_Control *freechain
89)
90{
91 return _Chain_Is_empty( &freechain->Free );
92}
93
101 RTEMS_INLINE_ROUTINE void *_Freechain_Pop( Freechain_Control *freechain )
102{
103 return _Chain_Get_first_unprotected( &freechain->Free );
104}
105
117void *_Freechain_Extend(
118 Freechain_Control *freechain,
119 Freechain_Allocator allocator,
120 size_t number_nodes_to_extend,
121 size_t node_size
122);
123
137void *_Freechain_Get(
138 Freechain_Control *freechain,
139 Freechain_Allocator allocator,
140 size_t number_nodes_to_extend,
141 size_t node_size
142);
143
151void _Freechain_Put(
152 Freechain_Control *freechain,
153 void *node
154);
155
158#ifdef __cplusplus
159}
160#endif
161
162#endif
163/* end of include file */
basedefs.h
Basic Definitions.
chainimpl.h
Chain Handler API.
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_Chain_Get_first_unprotected
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Get_first_unprotected(Chain_Control *the_chain)
Gets the first node (unprotected).
Definition: chainimpl.h:592
_Chain_Initialize
void _Chain_Initialize(Chain_Control *the_chain, void *starting_address, size_t number_nodes, size_t node_size)
Initializes a chain header.
Definition: chain.c:26
_Chain_Is_empty
RTEMS_INLINE_ROUTINE bool _Chain_Is_empty(const Chain_Control *the_chain)
Checks if the chain is empty.
Definition: chainimpl.h:393
_Freechain_Get
void * _Freechain_Get(Freechain_Control *freechain, Freechain_Allocator allocator, size_t number_nodes_to_extend, size_t node_size)
Gets a node from the freechain.
Definition: freechain.c:46
_Freechain_Pop
RTEMS_INLINE_ROUTINE void * _Freechain_Pop(Freechain_Control *freechain)
Pop an item from the freechain.
Definition: freechain.h:101
_Freechain_Put
void _Freechain_Put(Freechain_Control *freechain, void *node)
Puts a node back onto the freechain.
Definition: freechain.c:67
_Freechain_Is_empty
RTEMS_INLINE_ROUTINE bool _Freechain_Is_empty(const Freechain_Control *freechain)
Return true if the freechain is empty, otherwise false.
Definition: freechain.h:87
_Freechain_Initialize
RTEMS_INLINE_ROUTINE void _Freechain_Initialize(Freechain_Control *freechain, void *initial_nodes, size_t number_nodes, size_t node_size)
Initializes a freechain.
Definition: freechain.h:67
Freechain_Allocator
void *(* Freechain_Allocator)(size_t size)
Allocator function.
Definition: freechain.h:43
_Freechain_Extend
void * _Freechain_Extend(Freechain_Control *freechain, Freechain_Allocator allocator, size_t number_nodes_to_extend, size_t node_size)
Extend the freechain with new nodes.
Definition: freechain.c:24
Freechain_Control
The freechain control.
Definition: freechain.h:48
Freechain_Control::Free
Chain_Control Free
Chain of free nodes.
Definition: freechain.h:52
Chain_Control
Definition: chain.h:86