RTEMS 6.1-rc2
Loading...
Searching...
No Matches
freechainimpl.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (c) 2013 Gedare Bloom.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_SCORE_FREECHAINIMPL_H
38#define _RTEMS_SCORE_FREECHAINIMPL_H
39
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
57typedef void *( *Freechain_Allocator )( size_t size );
58
71static inline void _Freechain_Initialize(
72 Freechain_Control *freechain,
73 void *initial_nodes,
74 size_t number_nodes,
75 size_t node_size
76)
77{
79 &freechain->Free,
80 initial_nodes,
81 number_nodes,
82 node_size
83 );
84}
85
91static inline bool _Freechain_Is_empty(
92 const Freechain_Control *freechain
93)
94{
95 return _Chain_Is_empty( &freechain->Free );
96}
97
105static inline void *_Freechain_Pop( Freechain_Control *freechain )
106{
107 return _Chain_Get_first_unprotected( &freechain->Free );
108}
109
116void static inline _Freechain_Push(
117 Freechain_Control *freechain,
118 void *node
119)
120{
121 _Chain_Initialize_node( node );
122 _Chain_Prepend_unprotected( &freechain->Free, node );
123}
124
137 Freechain_Control *freechain,
138 Freechain_Allocator allocator,
139 size_t number_nodes_to_extend,
140 size_t node_size
141);
142
156void *_Freechain_Get(
157 Freechain_Control *freechain,
158 Freechain_Allocator allocator,
159 size_t number_nodes_to_extend,
160 size_t node_size
161);
162
170void _Freechain_Put(
171 Freechain_Control *freechain,
172 void *node
173);
174
177#ifdef __cplusplus
178}
179#endif
180
181#endif
182/* end of include file */
This header file provides basic definitions used by the API and the implementation.
This header file provides interfaces of the Chain Handler which are only used by the implementation.
This header file provides interfaces of the Freechain Handler which are used by the implementation an...
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:46
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:66
void _Freechain_Put(Freechain_Control *freechain, void *node)
Puts a node back onto the freechain.
Definition: freechain.c:87
void *(* Freechain_Allocator)(size_t size)
Allocator function.
Definition: freechainimpl.h:57
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:44
The freechain control.
Definition: freechain.h:64
Chain_Control Free
Chain of free nodes.
Definition: freechain.h:68