[rtems commit] score: Add _Freechain_Pop()
Sebastian Huber
sebh at rtems.org
Wed Feb 12 15:11:59 UTC 2020
Module: rtems
Branch: master
Commit: 4eab96bbb421018c17f984c1c3a4220abe16c788
Changeset: http://git.rtems.org/rtems/commit/?id=4eab96bbb421018c17f984c1c3a4220abe16c788
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Dec 10 10:59:02 2019 +0100
score: Add _Freechain_Pop()
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 bbae0b6..e656f64 100644
--- a/cpukit/include/rtems/score/freechain.h
+++ b/cpukit/include/rtems/score/freechain.h
@@ -92,6 +92,18 @@ RTEMS_INLINE_ROUTINE bool _Freechain_Is_empty(
}
/**
+ * @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.
*
* @param[in, out] freechain The freechain control.
diff --git a/testsuites/sptests/spfreechain01/init.c b/testsuites/sptests/spfreechain01/init.c
index 370bfb4..72cd792 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));
More information about the vc
mailing list