RTEMS  5.1
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
23 extern "C" {
24 #endif
25 
43 typedef void *( *Freechain_Allocator )( size_t size );
44 
48 typedef struct {
54 
68  Freechain_Control *freechain,
69  void *initial_nodes,
70  size_t number_nodes,
71  size_t node_size
72 )
73 {
75  &freechain->Free,
76  initial_nodes,
77  number_nodes,
78  node_size
79  );
80 }
81 
88  const Freechain_Control *freechain
89 )
90 {
91  return _Chain_Is_empty( &freechain->Free );
92 }
93 
102 {
103  return _Chain_Get_first_unprotected( &freechain->Free );
104 }
105 
117 void *_Freechain_Extend(
118  Freechain_Control *freechain,
119  Freechain_Allocator allocator,
120  size_t number_nodes_to_extend,
121  size_t node_size
122 );
123 
137 void *_Freechain_Get(
138  Freechain_Control *freechain,
139  Freechain_Allocator allocator,
140  size_t number_nodes_to_extend,
141  size_t node_size
142 );
143 
151 void _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 */
RTEMS_INLINE_ROUTINE bool _Freechain_Is_empty(const Freechain_Control *freechain)
Return true if the freechain is empty, otherwise false.
Definition: freechain.h:87
Definition: chain.h:86
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
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
RTEMS_INLINE_ROUTINE bool _Chain_Is_empty(const Chain_Control *the_chain)
Checks if the chain is empty.
Definition: chainimpl.h:393
Chain_Control Free
Chain of free nodes.
Definition: freechain.h:52
void _Freechain_Put(Freechain_Control *freechain, void *node)
Puts a node back onto the freechain.
Definition: freechain.c:67
void *(* Freechain_Allocator)(size_t size)
Allocator function.
Definition: freechain.h:43
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Get_first_unprotected(Chain_Control *the_chain)
Gets the first node (unprotected).
Definition: chainimpl.h:592
RTEMS_INLINE_ROUTINE void * _Freechain_Pop(Freechain_Control *freechain)
Pop an item from the freechain.
Definition: freechain.h:101
Chain Handler API.
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
Basic Definitions.
unsigned size
Definition: tte.h:74
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
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
The freechain control.
Definition: freechain.h:48