summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-12-10 10:58:42 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-02-12 09:08:40 +0100
commit8ff1af16551eedd7e98af6c65a91bb62b9403991 (patch)
treef322a211b4b709791115fb980891fc606ebb80fb
parent36e59b2bbc8737c4ba1b93ac0f695528a36844c9 (diff)
score: Add _Freechain_Is_empty()
Update #3835.
-rw-r--r--cpukit/include/rtems/score/freechain.h12
-rw-r--r--testsuites/sptests/spfreechain01/init.c3
2 files changed, 14 insertions, 1 deletions
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
@@ -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 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);