diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-08-10 08:21:54 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-09-06 10:52:20 +0200 |
commit | 3709987d968868d36701bf44474921b7cd560ce0 (patch) | |
tree | 8956017a0562ff14248ccb7fb1d14a6c10377444 | |
parent | score: Improve red-black tree debug support (diff) | |
download | rtems-3709987d968868d36701bf44474921b7cd560ce0.tar.bz2 |
score: Add _Chain_Initialize_one()
-rw-r--r-- | cpukit/score/include/rtems/score/chainimpl.h | 27 | ||||
-rw-r--r-- | testsuites/sptests/spchain/init.c | 23 | ||||
-rw-r--r-- | testsuites/sptests/spchain/spchain.scn | 1 |
3 files changed, 51 insertions, 0 deletions
diff --git a/cpukit/score/include/rtems/score/chainimpl.h b/cpukit/score/include/rtems/score/chainimpl.h index 4664175700..21c0e6b026 100644 --- a/cpukit/score/include/rtems/score/chainimpl.h +++ b/cpukit/score/include/rtems/score/chainimpl.h @@ -520,6 +520,33 @@ RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty( } /** + * @brief Initializes this chain to contain exactly the specified node. + * + * @param[in] the_chain The chain control. + * @param[in] the_node The one and only node. + */ +RTEMS_INLINE_ROUTINE void _Chain_Initialize_one( + Chain_Control *the_chain, + Chain_Node *the_node +) +{ + Chain_Node *head; + Chain_Node *tail; + + _Assert( _Chain_Is_node_off_chain( the_node ) ); + + head = _Chain_Head( the_chain ); + tail = _Chain_Tail( the_chain ); + + the_node->next = tail; + the_node->previous = head; + + head->next = the_node; + head->previous = NULL; + tail->previous = the_node; +} + +/** * @brief Extract this node (unprotected). * * This routine extracts the_node from the chain on which it resides. diff --git a/testsuites/sptests/spchain/init.c b/testsuites/sptests/spchain/init.c index eb5ea4e7df..8fa7ea087d 100644 --- a/testsuites/sptests/spchain/init.c +++ b/testsuites/sptests/spchain/init.c @@ -16,6 +16,28 @@ const char rtems_test_name[] = "SPCHAIN"; +static void test_chain_init_one(void) +{ + Chain_Control chain; + Chain_Node node; + + puts( "INIT - Verify _Chain_Initialize_one" ); + + _Chain_Initialize_node( &node ); + _Chain_Initialize_one( &chain, &node ); + rtems_test_assert( !_Chain_Is_empty( &chain ) ); + rtems_test_assert( !_Chain_Is_node_off_chain( &node ) ); + rtems_test_assert( _Chain_Is_first( &node ) ); + rtems_test_assert( _Chain_Is_last( &node ) ); + rtems_test_assert( _Chain_First( &chain ) == &node ); + rtems_test_assert( _Chain_Last( &chain ) == &node ); + rtems_test_assert( _Chain_Next( &node ) == _Chain_Tail( &chain ) ); + rtems_test_assert( _Chain_Previous( &node ) == _Chain_Head( &chain ) ); + + _Chain_Extract_unprotected( &node ); + rtems_test_assert( _Chain_Is_empty( &chain ) ); +} + static void update_registry_and_extract( Chain_Iterator_registry *reg, Chain_Node *n @@ -479,6 +501,7 @@ rtems_task Init( } } + test_chain_init_one(); test_chain_first_and_last(); test_chain_with_empty_check(); test_chain_with_notification(); diff --git a/testsuites/sptests/spchain/spchain.scn b/testsuites/sptests/spchain/spchain.scn index 4aff306362..e4cdf6e757 100644 --- a/testsuites/sptests/spchain/spchain.scn +++ b/testsuites/sptests/spchain/spchain.scn @@ -1,6 +1,7 @@ *** BEGIN OF TEST SPCHAIN *** Init - Initialize chain empty INIT - Verify rtems_chain_insert +INIT - Verify _Chain_Initialize_one INIT - Verify rtems_chain_is_first INIT - Verify rtems_chain_is_last INIT - Verify rtems_chain_append_with_empty_check |