forked from Imagelibrary/rtems
score: Add _Chain_Initialize_one()
This commit is contained in:
@@ -519,6 +519,33 @@ RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(
|
||||
tail->previous = head;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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).
|
||||
*
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user