RTEMS
freechainimpl.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_FREECHAINIMPL_H
17 #define _RTEMS_SCORE_FREECHAINIMPL_H
18 
19 #include <rtems/score/freechain.h>
20 #include <rtems/score/basedefs.h>
21 #include <rtems/score/chainimpl.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
36 typedef void *( *Freechain_Allocator )( size_t size );
37 
51  Freechain_Control *freechain,
52  void *initial_nodes,
53  size_t number_nodes,
54  size_t node_size
55 )
56 {
58  &freechain->Free,
59  initial_nodes,
60  number_nodes,
61  node_size
62  );
63 }
64 
71  const Freechain_Control *freechain
72 )
73 {
74  return _Chain_Is_empty( &freechain->Free );
75 }
76 
85 {
86  return _Chain_Get_first_unprotected( &freechain->Free );
87 }
88 
96  Freechain_Control *freechain,
97  void *node
98 )
99 {
100  _Chain_Initialize_node( node );
101  _Chain_Prepend_unprotected( &freechain->Free, node );
102 }
103 
115 void *_Freechain_Extend(
116  Freechain_Control *freechain,
117  Freechain_Allocator allocator,
118  size_t number_nodes_to_extend,
119  size_t node_size
120 );
121 
135 void *_Freechain_Get(
136  Freechain_Control *freechain,
137  Freechain_Allocator allocator,
138  size_t number_nodes_to_extend,
139  size_t node_size
140 );
141 
149 void _Freechain_Put(
150  Freechain_Control *freechain,
151  void *node
152 );
153 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif
161 /* end of include file */
static __inline__ void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:122
static __inline__ void _Freechain_Initialize(Freechain_Control *freechain, void *initial_nodes, size_t number_nodes, size_t node_size)
Initializes a freechain.
Definition: freechainimpl.h:50
static __inline__ Chain_Node * _Chain_Get_first_unprotected(Chain_Control *the_chain)
Gets the first node (unprotected).
Definition: chainimpl.h:592
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.
static __inline__ void * _Freechain_Pop(Freechain_Control *freechain)
Pops a node from the freechain.
Definition: freechainimpl.h:84
static __inline__ void _Chain_Prepend_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Prepends a node (unprotected).
Definition: chainimpl.h:732
Chain_Control Free
Chain of free nodes.
Definition: freechain.h:46
void _Freechain_Put(Freechain_Control *freechain, void *node)
Puts a node back onto the freechain.
void *(* Freechain_Allocator)(size_t size)
Allocator function.
Definition: freechainimpl.h:36
static __inline__ bool _Freechain_Is_empty(const Freechain_Control *freechain)
Return true if the freechain is empty, otherwise false.
Definition: freechainimpl.h:70
Chain Handler API.
static void __inline__ _Freechain_Push(Freechain_Control *freechain, void *node)
Pushes a node back to the freechain.
Definition: freechainimpl.h:95
Freechain Handler API.
This header file provides basic definitions used by the API and the implementation.
#define RTEMS_INLINE_ROUTINE
Gives a hint to the compiler in a function declaration to inline this function.
Definition: basedefs.h:683
static __inline__ bool _Chain_Is_empty(const Chain_Control *the_chain)
Checks if the chain is empty.
Definition: chainimpl.h:393
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.
The freechain control.
Definition: freechain.h:42