sapi: Add rtems_chain_get_first_unprotected()

Close #2459.
This commit is contained in:
Sebastian Huber
2015-11-03 11:10:21 +01:00
parent eab538cf9e
commit aa473025f7
3 changed files with 50 additions and 0 deletions

View File

@@ -623,6 +623,16 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_unprotected(
return _Chain_Get_unprotected( the_chain ); return _Chain_Get_unprotected( the_chain );
} }
/**
* @brief See _Chain_Get_first_unprotected().
*/
RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_first_unprotected(
rtems_chain_control *the_chain
)
{
return _Chain_Get_first_unprotected( the_chain );
}
/** /**
* @brief Insert a node on a chain * @brief Insert a node on a chain
* *

View File

@@ -35,6 +35,7 @@ provided by RTEMS is:
@item @code{@value{DIRPREFIX}chain_extract_unprotected} - Extract the node from the chain (unprotected) @item @code{@value{DIRPREFIX}chain_extract_unprotected} - Extract the node from the chain (unprotected)
@item @code{@value{DIRPREFIX}chain_get} - Return the first node on the chain @item @code{@value{DIRPREFIX}chain_get} - Return the first node on the chain
@item @code{@value{DIRPREFIX}chain_get_unprotected} - Return the first node on the chain (unprotected) @item @code{@value{DIRPREFIX}chain_get_unprotected} - Return the first node on the chain (unprotected)
@item @code{@value{DIRPREFIX}chain_get_first_unprotected} - Get the first node on the chain (unprotected)
@item @code{@value{DIRPREFIX}chain_insert} - Insert the node into the chain @item @code{@value{DIRPREFIX}chain_insert} - Insert the node into the chain
@item @code{@value{DIRPREFIX}chain_insert_unprotected} - Insert the node into the chain (unprotected) @item @code{@value{DIRPREFIX}chain_insert_unprotected} - Insert the node into the chain (unprotected)
@item @code{@value{DIRPREFIX}chain_append} - Append the node to chain @item @code{@value{DIRPREFIX}chain_append} - Append the node to chain
@@ -657,6 +658,38 @@ atomicity of the operation.
Use @code{@value{DIRPREFIX}chain_get_unprotected()} to avoid disabling of Use @code{@value{DIRPREFIX}chain_get_unprotected()} to avoid disabling of
interrupts. interrupts.
@c
@c
@c
@page
@subsection Get the First Node (unprotected)
@cindex chain get first node
@subheading CALLING SEQUENCE:
@ifset is-C
@findex @value{DIRPREFIX}chain_get_first_unprotected
@example
@value{DIRPREFIX}chain_node *@value{DIRPREFIX}chain_get_first_unprotected(
@value{DIRPREFIX}chain_control *the_chain
);
@end example
@end ifset
@subheading RETURNS:
A pointer to the former first node is returned.
@subheading DESCRIPTION:
Removes the first node from the chain and returns a pointer to it. In case the
chain was empty, then the results are unpredictable.
@subheading NOTES:
The function does nothing to ensure the atomicity of the operation.
@c @c
@c @c
@c @c

View File

@@ -117,6 +117,13 @@ static void test_chain_first_and_last(void)
puts( "INIT - Verify rtems_chain_is_last" ); puts( "INIT - Verify rtems_chain_is_last" );
cnode = rtems_chain_last(&chain); cnode = rtems_chain_last(&chain);
rtems_test_assert( rtems_chain_is_last( cnode ) ); rtems_test_assert( rtems_chain_is_last( cnode ) );
cnode = rtems_chain_get_first_unprotected( &chain );
rtems_test_assert( cnode == &node1 );
cnode = rtems_chain_first( &chain );
rtems_test_assert( cnode == &node2 );
cnode = rtems_chain_last( &chain );
rtems_test_assert( cnode == &node2 );
} }
static void test_chain_with_notification(void) static void test_chain_with_notification(void)