diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-06-12 11:29:12 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-06-14 16:26:06 +0200 |
commit | ec978d97e028a538598f4b08b2e018d4912f0f7e (patch) | |
tree | c02e8520d2451bd79bdc05b63582fc62f994703b /cpukit/score | |
parent | rtems: Simplify rtems_task_mode() (diff) | |
download | rtems-ec978d97e028a538598f4b08b2e018d4912f0f7e.tar.bz2 |
score: Add _Chain_Insert_ordered_unprotected()
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/inline/rtems/score/chain.inl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cpukit/score/inline/rtems/score/chain.inl b/cpukit/score/inline/rtems/score/chain.inl index 7290d6ecac..190eedf8d6 100644 --- a/cpukit/score/inline/rtems/score/chain.inl +++ b/cpukit/score/inline/rtems/score/chain.inl @@ -726,6 +726,47 @@ RTEMS_INLINE_ROUTINE bool _Chain_Get_with_empty_check_unprotected( return is_empty_now; } +/** + * @brief Chain node order. + * + * @param[in] left The left node. + * @param[in] right The right node. + * + * @retval true According to the order the left node precedes the right node. + * @retval false Otherwise. + */ +typedef bool ( *Chain_Node_order )( + const Chain_Node *left, + const Chain_Node *right +); + +/** + * @brief Inserts a node into the chain according to the order relation. + * + * After the operation the chain contains the node to insert and the order + * relation holds for all nodes from the head up to the inserted node. Nodes + * after the inserted node are not moved. + * + * @param[in/out] chain The chain. + * @param[in/out] to_insert The node to insert. + * @param[in] order The order relation. + */ +RTEMS_INLINE_ROUTINE void _Chain_Insert_ordered_unprotected( + Chain_Control *chain, + Chain_Node *to_insert, + Chain_Node_order order +) +{ + const Chain_Node *tail = _Chain_Immutable_tail( chain ); + Chain_Node *next = _Chain_First( chain ); + + while ( next != tail && !( *order )( to_insert, next ) ) { + next = _Chain_Next( next ); + } + + _Chain_Insert_unprotected( _Chain_Previous( next ), to_insert ); +} + /** @} */ #endif |