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) 146 return node->
next == NULL;
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;
436 return (the_node->
next->
next == NULL);
541 the_node->
next = tail;
544 head->
next = the_node;
567 next = the_node->
next;
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,
static __inline__ void _Chain_Iterator_destroy(Chain_Iterator *the_iterator)
Destroys the iterator.
static __inline__ 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).
bool(* Chain_Node_order)(const void *left, const Chain_Node *right)
Chain node order.
static __inline__ Chain_Node * _Chain_First(const Chain_Control *the_chain)
Returns pointer to chain's first node.
static __inline__ bool _Chain_Is_first(const Chain_Node *the_node)
Checks if this is the first node on the chain.
static __inline__ void _Chain_Iterator_set_position(Chain_Iterator *the_iterator, Chain_Node *the_node)
Sets the iterator position.
static __inline__ bool _Chain_Are_nodes_equal(const Chain_Node *left, const Chain_Node *right)
Checks if two nodes are equal.
Chain_Node Registry_node
Node for registration.
A chain iterator which is updated during node extraction if it is properly registered.
static __inline__ 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.
static __inline__ bool _Chain_Is_node_off_chain(const Chain_Node *node)
Checks if the node is off chain.
static __inline__ bool _Chain_Is_last(const Chain_Node *the_node)
Checks if this is the last node on the chain.
static __inline__ void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
static __inline__ 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).
static __inline__ const Chain_Node * _Chain_Immutable_previous(const Chain_Node *the_node)
Returns pointer to the immutable previous node from this node.
static __inline__ void _Chain_Iterator_registry_initialize(Chain_Iterator_registry *the_registry)
Initializes a chain iterator registry.
static __inline__ Chain_Node * _Chain_Get_first_unprotected(Chain_Control *the_chain)
Gets the first node (unprotected).
void _Chain_Initialize(Chain_Control *the_chain, void *starting_address, size_t number_nodes, size_t node_size)
Initializes a chain header.
size_t _Chain_Node_count_unprotected(const Chain_Control *chain)
Returns the node count of the chain.
static __inline__ bool _Chain_Is_head(const Chain_Control *the_chain, const Chain_Node *the_node)
Checks if this node is the chain head.
static __inline__ void _Chain_Insert_unprotected(Chain_Node *after_node, Chain_Node *the_node)
Inserts a node (unprotected).
Information for the Assert Handler.
static __inline__ void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Appends a node (unprotected).
static __inline__ void _Chain_Prepend_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Prepends a node (unprotected).
static __inline__ bool _Chain_Is_null_node(const Chain_Node *the_node)
Checks if the chain node pointer is NULL.
static __inline__ Chain_Node * _Chain_Next(const Chain_Node *the_node)
Returns pointer to the next node from this node.
static __inline__ Chain_Node * _Chain_Head(Chain_Control *the_chain)
Returns pointer to chain head.
static __inline__ bool _Chain_Has_only_one_node(const Chain_Control *the_chain)
Checks if this chain has only one node.
static __inline__ void _Chain_Extract_unprotected(Chain_Node *the_node)
Extracts this node (unprotected).
static __inline__ const Chain_Node * _Chain_Immutable_next(const Chain_Node *the_node)
Returns pointer to the immutable next node from this node.
static __inline__ Chain_Node * _Chain_Iterator_next(const Chain_Iterator *the_iterator)
Returns the next node in the iterator direction.
static __inline__ void _Chain_Initialize_one(Chain_Control *the_chain, Chain_Node *the_node)
Initializes this chain to contain exactly the specified node.
static __inline__ void _Chain_Initialize_empty(Chain_Control *the_chain)
Initializes this chain as empty.
static __inline__ const Chain_Node * _Chain_Immutable_first(const Chain_Control *the_chain)
Returns pointer to immutable chain's first node.
Iteration from head to tail.
static __inline__ Chain_Node * _Chain_Last(const Chain_Control *the_chain)
Returns pointer to chain's last node.
static __inline__ Chain_Node * _Chain_Previous(const Chain_Node *the_node)
Returns pointer to the previous node from this node.
static __inline__ void _Chain_Set_off_chain(Chain_Node *node)
Sets off chain.
static __inline__ const Chain_Node * _Chain_Immutable_head(const Chain_Control *the_chain)
Returns pointer to immutable chain head.
static __inline__ const Chain_Node * _Chain_Immutable_last(const Chain_Control *the_chain)
Returns pointer to immutable chain's last node.
Chain_Iterator_direction
The chain iterator direction.
#define RTEMS_INLINE_ROUTINE
Gives a hint to the compiler in a function declaration to inline this function.
static __inline__ 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.
Chain_Iterator_direction direction
The direction of this iterator.
static __inline__ 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.
Iteration from tail to head.
static __inline__ 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).
static __inline__ bool _Chain_Is_empty(const Chain_Control *the_chain)
Checks if the chain is empty.
static __inline__ 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).
Chain_Node * position
The current position of this iterator.
static __inline__ Chain_Node * _Chain_Tail(Chain_Control *the_chain)
Returns pointer to chain tail.
static __inline__ bool _Chain_Is_tail(const Chain_Control *the_chain, const Chain_Node *the_node)
Checks if this node is the chain tail.
static __inline__ const Chain_Node * _Chain_Immutable_tail(const Chain_Control *the_chain)
Returns pointer to immutable chain tail.
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
A registry for chain iterators.
static __inline__ Chain_Node * _Chain_Get_unprotected(Chain_Control *the_chain)
Gets the first node (unprotected).