20 #ifndef _RTEMS_SCORE_CHAINIMPL_H 21 #define _RTEMS_SCORE_CHAINIMPL_H 39 #define CHAIN_INITIALIZER_EMPTY(name) \ 40 { { { &(name).Tail.Node, NULL }, &(name).Head.Node } } 47 #define CHAIN_INITIALIZER_ONE_NODE( node ) \ 48 { { { (node), NULL }, (node) } } 55 #define CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \ 56 { &(chain)->Tail.Node, &(chain)->Head.Node } 61 #define CHAIN_DEFINE_EMPTY(name) \ 62 Chain_Control name = CHAIN_INITIALIZER_EMPTY(name) 79 void *starting_address,
109 #if defined(RTEMS_DEBUG) 124 #if defined(RTEMS_DEBUG) 166 return left == right;
183 return (the_node ==
NULL);
199 return &the_chain->Head.Node;
215 return &the_chain->Head.Node;
231 return &the_chain->Tail.Node;
247 return &the_chain->Tail.Node;
331 return the_node->
next;
347 return the_node->
next;
518 head->previous =
NULL;
541 the_node->
next = tail;
544 head->next = the_node;
545 head->previous =
NULL;
567 next = the_node->
next;
569 next->previous = previous;
570 previous->
next = next;
572 #if defined(RTEMS_DEBUG) 603 old_first = head->next;
604 new_first = old_first->
next;
606 head->next = new_first;
609 #if defined(RTEMS_DEBUG) 663 before_node = after_node->
next;
664 after_node->
next = the_node;
665 the_node->
next = before_node;
693 the_node->
next = tail;
695 old_last->
next = the_node;
815 bool is_empty_now =
true;
820 if ( old_first != tail ) {
823 head->next = new_first;
826 *the_node = old_first;
828 is_empty_now = new_first == tail;
874 while ( next != tail && !( *order )( left, next ) ) {
943 #define CHAIN_ITERATOR_REGISTRY_INITIALIZER( name ) \ 944 { CHAIN_INITIALIZER_EMPTY( name.Iterators ) } 978 iter_node =
_Chain_Head( &the_registry->Iterators );
979 iter_tail =
_Chain_Tail( &the_registry->Iterators );
981 while ( ( iter_node =
_Chain_Next( iter_node ) ) != iter_tail ) {
986 if ( iter->
position == the_node_to_extract ) {
1066 &the_registry->Iterators,
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:1057
RTEMS_INLINE_ROUTINE bool _Chain_Is_head(const Chain_Control *the_chain, const Chain_Node *the_node)
Checks if this node is the chain head.
Definition: chainimpl.h:470
RTEMS_INLINE_ROUTINE bool _Chain_Append_with_empty_check_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node and checks if the chain was empty before (unprotected).
Definition: chainimpl.h:754
RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected(Chain_Node *the_node)
Extracts this node (unprotected).
Definition: chainimpl.h:558
bool(* Chain_Node_order)(const void *left, const Chain_Node *right)
Chain node order.
Definition: chainimpl.h:844
Chain_Node * previous
Definition: chain.h:72
RTEMS_INLINE_ROUTINE void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:122
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Tail(Chain_Control *the_chain)
Returns pointer to chain tail.
Definition: chainimpl.h:227
RTEMS_INLINE_ROUTINE void _Chain_Iterator_destroy(Chain_Iterator *the_iterator)
Destroys the iterator.
Definition: chainimpl.h:1121
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Next(const Chain_Node *the_node)
Returns pointer to the next node from this node.
Definition: chainimpl.h:327
Chain_Node Registry_node
Node for registration.
Definition: chainimpl.h:908
A chain iterator which is updated during node extraction if it is properly registered.
Definition: chainimpl.h:902
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Head(Chain_Control *the_chain)
Returns pointer to chain head.
Definition: chainimpl.h:195
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_next(const Chain_Node *the_node)
Returns pointer to the immutable next node from this node.
Definition: chainimpl.h:343
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_head(const Chain_Control *the_chain)
Returns pointer to immutable chain head.
Definition: chainimpl.h:211
RTEMS_INLINE_ROUTINE void _Chain_Set_off_chain(Chain_Node *node)
Sets off chain.
Definition: chainimpl.h:104
RTEMS_INLINE_ROUTINE bool _Chain_Is_tail(const Chain_Control *the_chain, const Chain_Node *the_node)
Checks if this node is the chain tail.
Definition: chainimpl.h:490
RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(Chain_Control *the_chain)
Initializes this chain as empty.
Definition: chainimpl.h:505
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_first(const Chain_Control *the_chain)
Returns pointer to immutable chain's first node.
Definition: chainimpl.h:277
void _Chain_Initialize(Chain_Control *the_chain, void *starting_address, size_t number_nodes, size_t node_size)
Initializes a chain header.
Definition: chain.c:26
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:970
size_t _Chain_Node_count_unprotected(const Chain_Control *chain)
Returns the node count of the chain.
Definition: chainnodecount.c:21
RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_initialize(Chain_Iterator_registry *the_registry)
Initializes a chain iterator registry.
Definition: chainimpl.h:951
Information for the Assert Handler.
RTEMS_INLINE_ROUTINE bool _Chain_Is_empty(const Chain_Control *the_chain)
Checks if the chain is empty.
Definition: chainimpl.h:393
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_First(const Chain_Control *the_chain)
Returns pointer to chain's first node.
Definition: chainimpl.h:260
Chain_Node * next
Definition: chain.h:70
RTEMS_INLINE_ROUTINE bool _Chain_Are_nodes_equal(const Chain_Node *left, const Chain_Node *right)
Checks if two nodes are equal.
Definition: chainimpl.h:161
RTEMS_INLINE_ROUTINE bool _Chain_Is_last(const Chain_Node *the_node)
Checks if this is the last node on the chain.
Definition: chainimpl.h:432
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Get_first_unprotected(Chain_Control *the_chain)
Gets the first node (unprotected).
Definition: chainimpl.h:592
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_tail(const Chain_Control *the_chain)
Returns pointer to immutable chain tail.
Definition: chainimpl.h:243
RTEMS_INLINE_ROUTINE bool _Chain_Has_only_one_node(const Chain_Control *the_chain)
Checks if this chain has only one node.
Definition: chainimpl.h:450
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:528
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_previous(const Chain_Node *the_node)
Returns pointer to the immutable previous node from this node.
Definition: chainimpl.h:375
RTEMS_INLINE_ROUTINE void _Chain_Insert_unprotected(Chain_Node *after_node, Chain_Node *the_node)
Inserts a node (unprotected).
Definition: chainimpl.h:653
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Last(const Chain_Control *the_chain)
Returns pointer to chain's last node.
Definition: chainimpl.h:294
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:864
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Previous(const Chain_Node *the_node)
Returns pointer to the previous node from this node.
Definition: chainimpl.h:359
RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
Definition: chainimpl.h:680
RTEMS_INLINE_ROUTINE bool _Chain_Is_first(const Chain_Node *the_node)
Checks if this is the first node on the chain.
Definition: chainimpl.h:413
RTEMS_INLINE_ROUTINE bool _Chain_Is_null_node(const Chain_Node *the_node)
Checks if the chain node pointer is NULL.
Definition: chainimpl.h:179
RTEMS_INLINE_ROUTINE bool _Chain_Prepend_with_empty_check_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Prepends a node and checks if the chain was empty before (unprotected).
Definition: chainimpl.h:780
Iteration from head to tail.
Definition: chainimpl.h:888
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Iterator_next(const Chain_Iterator *the_iterator)
Returns the next node in the iterator direction.
Definition: chainimpl.h:1089
RTEMS_INLINE_ROUTINE void _Chain_Iterator_set_position(Chain_Iterator *the_iterator, Chain_Node *the_node)
Sets the iterator position.
Definition: chainimpl.h:1106
RTEMS_INLINE_ROUTINE void _Chain_Append_if_is_off_chain_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node on the end of a chain if the node is in the off chain state (unprotected).
Definition: chainimpl.h:711
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_last(const Chain_Control *the_chain)
Returns pointer to immutable chain's last node.
Definition: chainimpl.h:311
Chain_Iterator_direction
The chain iterator direction.
Definition: chainimpl.h:884
RTEMS_INLINE_ROUTINE bool _Chain_Is_node_off_chain(const Chain_Node *node)
Checks if the node is off chain.
Definition: chainimpl.h:142
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Get_unprotected(Chain_Control *the_chain)
Gets the first node (unprotected).
Definition: chainimpl.h:630
Chain_Iterator_direction direction
The direction of this iterator.
Definition: chainimpl.h:915
Iteration from tail to head.
Definition: chainimpl.h:893
RTEMS_INLINE_ROUTINE void _Chain_Prepend_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Prepends a node (unprotected).
Definition: chainimpl.h:732
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
RTEMS_INLINE_ROUTINE bool _Chain_Get_with_empty_check_unprotected(Chain_Control *the_chain, Chain_Node **the_node)
Gets the first node and checks if the chain is empty afterwards (unprotected).
Definition: chainimpl.h:810
Chain_Node * position
The current position of this iterator.
Definition: chainimpl.h:925
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
A registry for chain iterators.
Definition: chainimpl.h:934
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77