[PATCH 18/21] score: Add _Freechain_Pop()

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Dec 16 14:28:23 UTC 2019


Update #3835.
---
 cpukit/include/rtems/score/freechain.h  | 12 ++++++++++++
 testsuites/sptests/spfreechain01/init.c |  4 ++++
 2 files changed, 16 insertions(+)

diff --git a/cpukit/include/rtems/score/freechain.h b/cpukit/include/rtems/score/freechain.h
index bbae0b65bb..e656f64f8e 100644
--- a/cpukit/include/rtems/score/freechain.h
+++ b/cpukit/include/rtems/score/freechain.h
@@ -91,6 +91,18 @@ RTEMS_INLINE_ROUTINE bool _Freechain_Is_empty(
   return _Chain_Is_empty( &freechain->Free );
 }
 
+/**
+ * @brief Pop an item from the freechain.
+ *
+ * The freechain must not be empty.
+ *
+ * @param freechain The freechain control.
+ */
+RTEMS_INLINE_ROUTINE void *_Freechain_Pop( Freechain_Control *freechain )
+{
+  return _Chain_Get_first_unprotected( &freechain->Free );
+}
+
 /**
  * @brief Gets a node from the freechain.
  *
diff --git a/testsuites/sptests/spfreechain01/init.c b/testsuites/sptests/spfreechain01/init.c
index 370bfb41eb..72cd7920c5 100644
--- a/testsuites/sptests/spfreechain01/init.c
+++ b/testsuites/sptests/spfreechain01/init.c
@@ -35,6 +35,10 @@ static rtems_task Init(rtems_task_argument ignored)
     rtems_test_assert(_Chain_First(&fc.Free) == &node2.Node);
     rtems_test_assert(_Chain_Last(&fc.Free) == &node2.Node);
 
+    node = _Freechain_Pop(&fc);
+    rtems_test_assert(_Freechain_Is_empty(&fc));
+    rtems_test_assert(node == &node2);
+
     _Freechain_Initialize(&fc, NULL, 0, sizeof(test_node));
     rtems_test_assert(_Freechain_Is_empty(&fc));
 
-- 
2.16.4



More information about the devel mailing list