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