summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-12 11:29:12 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-06-14 16:26:06 +0200
commitec978d97e028a538598f4b08b2e018d4912f0f7e (patch)
treec02e8520d2451bd79bdc05b63582fc62f994703b /cpukit/score
parent7a34ca371b606093a338a11b6fbd1380d382808d (diff)
downloadrtems-ec978d97e028a538598f4b08b2e018d4912f0f7e.tar.bz2
score: Add _Chain_Insert_ordered_unprotected()
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/inline/rtems/score/chain.inl41
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