18 #ifndef _RTEMS_SCORE_CHAINIMPL_H 19 #define _RTEMS_SCORE_CHAINIMPL_H 22 #include <rtems/score/assert.h> 36 #define CHAIN_INITIALIZER_EMPTY(name) \ 37 { { { &(name).Tail.Node, NULL }, &(name).Head.Node } } 44 #define CHAIN_INITIALIZER_ONE_NODE( node ) \ 45 { { { (node), NULL }, (node) } } 52 #define CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \ 53 { &(chain)->Tail.Node, &(chain)->Head.Node } 58 #define CHAIN_DEFINE_EMPTY(name) \ 59 Chain_Control name = CHAIN_INITIALIZER_EMPTY(name) 76 void *starting_address,
106 #if defined(RTEMS_DEBUG) 121 #if defined(RTEMS_DEBUG) 163 return left == right;
180 return (the_node ==
NULL);
196 return &the_chain->Head.Node;
212 return &the_chain->Head.Node;
228 return &the_chain->Tail.Node;
244 return &the_chain->Tail.Node;
328 return the_node->
next;
344 return the_node->
next;
511 _Assert( the_chain !=
NULL );
540 the_node->
next = tail;
543 head->
next = the_node;
566 next = the_node->
next;
569 previous->
next = next;
571 #if defined(RTEMS_DEBUG) 602 old_first = head->
next;
603 new_first = old_first->
next;
605 head->
next = new_first;
608 #if defined(RTEMS_DEBUG) 662 before_node = after_node->
next;
663 after_node->
next = the_node;
664 the_node->
next = before_node;
692 the_node->
next = tail;
694 old_last->
next = the_node;
811 bool is_empty_now =
true;
816 if ( old_first != tail ) {
819 head->
next = new_first;
822 *the_node = old_first;
824 is_empty_now = new_first == tail;
870 while ( next != tail && !( *order )( left, next ) ) {
939 #define CHAIN_ITERATOR_REGISTRY_INITIALIZER( name ) \ 940 { CHAIN_INITIALIZER_EMPTY( name.Iterators ) } 969 iter_node =
_Chain_Head( &the_registry->Iterators );
970 iter_tail =
_Chain_Tail( &the_registry->Iterators );
972 while ( ( iter_node =
_Chain_Next( iter_node ) ) != iter_tail ) {
977 if ( iter->
position == the_node_to_extract ) {
1052 Chain_Iterator_direction direction
1057 &the_registry->Iterators,
RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Append a node (unprotected).
Definition: chainimpl.h:679
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Head(Chain_Control *the_chain)
Return pointer to chain head.
Definition: chainimpl.h:192
Chain_Node * previous
Definition: chain.h:69
RTEMS_INLINE_ROUTINE void _Chain_Insert_ordered_unprotected(Chain_Control *the_chain, Chain_Node *to_insert, const void *left, Chain_Node_order order)
Inserts a node into the chain according to the order relation.
Definition: chainimpl.h:860
RTEMS_INLINE_ROUTINE void _Chain_Iterator_set_position(Chain_Iterator *the_iterator, Chain_Node *the_node)
Sets the iterator position.
Definition: chainimpl.h:1095
Chain_Node Registry_node
Node for registration.
Definition: chainimpl.h:904
A chain iterator which is updated during node extraction if it is properly registered.
Definition: chainimpl.h:898
void _Chain_Initialize(Chain_Control *the_chain, void *starting_address, size_t number_nodes, size_t node_size)
Initialize a chain header.
Definition: chain.c:26
RTEMS_INLINE_ROUTINE bool _Chain_Prepend_with_empty_check_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Prepend a node and check if the chain was empty before (unprotected).
Definition: chainimpl.h:776
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
RTEMS_INLINE_ROUTINE void _Chain_Iterator_destroy(Chain_Iterator *the_iterator)
Destroys the iterator.
Definition: chainimpl.h:1110
RTEMS_INLINE_ROUTINE void _Chain_Iterator_initialize(Chain_Control *the_chain, Chain_Iterator_registry *the_registry, Chain_Iterator *the_iterator, Chain_Iterator_direction direction)
Initializes the chain iterator.
Definition: chainimpl.h:1048
RTEMS_INLINE_ROUTINE bool _Chain_Are_nodes_equal(const Chain_Node *left, const Chain_Node *right)
Are two nodes equal.
Definition: chainimpl.h:158
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_head(const Chain_Control *the_chain)
Return pointer to immutable chain head.
Definition: chainimpl.h:208
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Iterator_next(const Chain_Iterator *the_iterator)
Returns the next node in the iterator direction.
Definition: chainimpl.h:1078
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Next(const Chain_Node *the_node)
Return pointer the next node from this node.
Definition: chainimpl.h:324
RTEMS_INLINE_ROUTINE bool _Chain_Is_node_off_chain(const Chain_Node *node)
Is the node off chain.
Definition: chainimpl.h:139
RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected(Chain_Node *the_node)
Extract this node (unprotected).
Definition: chainimpl.h:557
RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(Chain_Control *the_chain)
Initialize this chain as empty.
Definition: chainimpl.h:504
RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_initialize(Chain_Iterator_registry *the_registry)
Initializes a chain iterator registry.
Definition: chainimpl.h:945
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_previous(const Chain_Node *the_node)
Return pointer the immutable previous node from this node.
Definition: chainimpl.h:372
RTEMS_INLINE_ROUTINE bool _Chain_Is_empty(const Chain_Control *the_chain)
Is the chain empty.
Definition: chainimpl.h:390
Chain_Node * next
Definition: chain.h:67
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_First(const Chain_Control *the_chain)
Return pointer to chain's first node.
Definition: chainimpl.h:257
RTEMS_INLINE_ROUTINE bool _Chain_Has_only_one_node(const Chain_Control *the_chain)
Does this chain have only one node.
Definition: chainimpl.h:449
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Get_unprotected(Chain_Control *the_chain)
Get the first node (unprotected).
Definition: chainimpl.h:629
RTEMS_INLINE_ROUTINE bool _Chain_Get_with_empty_check_unprotected(Chain_Control *the_chain, Chain_Node **the_node)
Get the first node and check if the chain is empty afterwards (unprotected).
Definition: chainimpl.h:806
RTEMS_INLINE_ROUTINE bool _Chain_Append_with_empty_check_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Append a node and check if the chain was empty before (unprotected).
Definition: chainimpl.h:750
size_t _Chain_Node_count_unprotected(const Chain_Control *chain)
Returns the node count of the chain.
Definition: chainnodecount.c:21
RTEMS_INLINE_ROUTINE bool _Chain_Is_last(const Chain_Node *the_node)
Is this the last node on the chain.
Definition: chainimpl.h:428
Iteration from head to tail.
Definition: chainimpl.h:884
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_first(const Chain_Control *the_chain)
Return pointer to immutable chain's first node.
Definition: chainimpl.h:274
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Tail(Chain_Control *the_chain)
Return pointer to chain tail.
Definition: chainimpl.h:224
bool(* Chain_Node_order)(const void *left, const Chain_Node *right)
Chain node order.
Definition: chainimpl.h:840
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_next(const Chain_Node *the_node)
Return pointer the immutable next node from this node.
Definition: chainimpl.h:340
RTEMS_INLINE_ROUTINE void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:119
RTEMS_INLINE_ROUTINE void _Chain_Insert_unprotected(Chain_Node *after_node, Chain_Node *the_node)
Insert a node (unprotected).
Definition: chainimpl.h:652
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Previous(const Chain_Node *the_node)
Return pointer the previous node from this node.
Definition: chainimpl.h:356
RTEMS_INLINE_ROUTINE bool _Chain_Is_tail(const Chain_Control *the_chain, const Chain_Node *the_node)
Is this node the chail tail.
Definition: chainimpl.h:489
RTEMS_INLINE_ROUTINE bool _Chain_Is_first(const Chain_Node *the_node)
Is this the first node on the chain.
Definition: chainimpl.h:410
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Get_first_unprotected(Chain_Control *the_chain)
Get the first node (unprotected).
Definition: chainimpl.h:591
RTEMS_INLINE_ROUTINE void _Chain_Set_off_chain(Chain_Node *node)
Set off chain.
Definition: chainimpl.h:101
Chain_Iterator_direction
The chain iterator direction.
Definition: chainimpl.h:880
RTEMS_INLINE_ROUTINE bool _Chain_Is_null_node(const Chain_Node *the_node)
Is the chain node pointer NULL.
Definition: chainimpl.h:176
Iteration from tail to head.
Definition: chainimpl.h:889
Chain_Iterator_direction direction
The direction of this iterator.
Definition: chainimpl.h:911
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_tail(const Chain_Control *the_chain)
Return pointer to immutable chain tail.
Definition: chainimpl.h:240
RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_update(Chain_Iterator_registry *the_registry, Chain_Node *the_node_to_extract)
Updates all iterators present in the chain iterator registry in case of a node extraction.
Definition: chainimpl.h:961
RTEMS_INLINE_ROUTINE bool _Chain_Is_head(const Chain_Control *the_chain, const Chain_Node *the_node)
Is this node the chain head.
Definition: chainimpl.h:469
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_last(const Chain_Control *the_chain)
Return pointer to immutable chain's last node.
Definition: chainimpl.h:308
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Last(const Chain_Control *the_chain)
Return pointer to chain's last node.
Definition: chainimpl.h:291
RTEMS_INLINE_ROUTINE void _Chain_Append_if_is_off_chain_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Append a node on the end of a chain if the node is in the off chain state (unprotected).
Definition: chainimpl.h:707
RTEMS_INLINE_ROUTINE void _Chain_Prepend_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Prepend a node (unprotected).
Definition: chainimpl.h:728
Chain_Node * position
The current position of this iterator.
Definition: chainimpl.h:921
RTEMS_INLINE_ROUTINE void _Chain_Initialize_one(Chain_Control *the_chain, Chain_Node *the_node)
Initializes this chain to contain exactly the specified node.
Definition: chainimpl.h:527
A registry for chain iterators.
Definition: chainimpl.h:930
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77