From 8ff1af16551eedd7e98af6c65a91bb62b9403991 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 10 Dec 2019 10:58:42 +0100 Subject: 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 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); -- cgit v1.2.3