[PATCH 1/7] score: Add _Freechain_Push()
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Aug 21 11:50:57 UTC 2020
Update #3959.
---
cpukit/include/rtems/score/freechain.h | 19 +++++++++++++++++--
cpukit/score/src/freechain.c | 3 +--
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/cpukit/include/rtems/score/freechain.h b/cpukit/include/rtems/score/freechain.h
index eaee077366..ab1e8150da 100644
--- a/cpukit/include/rtems/score/freechain.h
+++ b/cpukit/include/rtems/score/freechain.h
@@ -92,9 +92,9 @@ RTEMS_INLINE_ROUTINE bool _Freechain_Is_empty(
}
/**
- * @brief Pop an item from the freechain.
+ * @brief Pops a node from the freechain.
*
- * The freechain must not be empty.
+ * The freechain shall not be empty.
*
* @param freechain The freechain control.
*/
@@ -103,6 +103,21 @@ RTEMS_INLINE_ROUTINE void *_Freechain_Pop( Freechain_Control *freechain )
return _Chain_Get_first_unprotected( &freechain->Free );
}
+/**
+ * @brief Pushes a node back to the freechain.
+ *
+ * @param freechain The freechain control.
+ * @param node The node to push back. The node shall not be @c NULL.
+ */
+void RTEMS_INLINE_ROUTINE _Freechain_Push(
+ Freechain_Control *freechain,
+ void *node
+)
+{
+ _Chain_Initialize_node( node );
+ _Chain_Prepend_unprotected( &freechain->Free, node );
+}
+
/**
* @brief Extend the freechain with new nodes.
*
diff --git a/cpukit/score/src/freechain.c b/cpukit/score/src/freechain.c
index 7f60c655db..209a2b780d 100644
--- a/cpukit/score/src/freechain.c
+++ b/cpukit/score/src/freechain.c
@@ -67,7 +67,6 @@ void *_Freechain_Get(
void _Freechain_Put( Freechain_Control *freechain, void *node )
{
if ( node != NULL ) {
- _Chain_Initialize_node( node );
- _Chain_Prepend_unprotected( &freechain->Free, node );
+ _Freechain_Push( freechain, node );
}
}
--
2.26.2
More information about the devel
mailing list