[PATCH 17/21] score: Add _Freechain_Is_empty()
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Dec 16 14:28:22 UTC 2019
Update #3835.
---
cpukit/include/rtems/score/freechain.h | 12 ++++++++++++
testsuites/sptests/spfreechain01/init.c | 3 ++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/cpukit/include/rtems/score/freechain.h b/cpukit/include/rtems/score/freechain.h
index e65eba1448..bbae0b65bb 100644
--- a/cpukit/include/rtems/score/freechain.h
+++ b/cpukit/include/rtems/score/freechain.h
@@ -79,6 +79,18 @@ RTEMS_INLINE_ROUTINE void _Freechain_Initialize(
);
}
+/**
+ * @brief Return true if the freechain is empty, otherwise false
+ *
+ * @param freechain The freechain control.
+ */
+RTEMS_INLINE_ROUTINE bool _Freechain_Is_empty(
+ const Freechain_Control *freechain
+)
+{
+ return _Chain_Is_empty( &freechain->Free );
+}
+
/**
* @brief Gets a node from the freechain.
*
diff --git a/testsuites/sptests/spfreechain01/init.c b/testsuites/sptests/spfreechain01/init.c
index 22730793a4..370bfb41eb 100644
--- a/testsuites/sptests/spfreechain01/init.c
+++ b/testsuites/sptests/spfreechain01/init.c
@@ -30,12 +30,13 @@ static rtems_task Init(rtems_task_argument ignored)
TEST_BEGIN();
_Freechain_Initialize(&fc, &node2, 1, sizeof(node2));
+ rtems_test_assert(!_Freechain_Is_empty(&fc));
rtems_test_assert(_Chain_Node_count_unprotected(&fc.Free) == 1);
rtems_test_assert(_Chain_First(&fc.Free) == &node2.Node);
rtems_test_assert(_Chain_Last(&fc.Free) == &node2.Node);
_Freechain_Initialize(&fc, NULL, 0, sizeof(test_node));
- rtems_test_assert(_Chain_Is_empty(&fc.Free));
+ rtems_test_assert(_Freechain_Is_empty(&fc));
rtems_test_assert(_Freechain_Get(&fc, NULL, 0, sizeof(test_node)) == NULL);
--
2.16.4
More information about the devel
mailing list