Merge branch "preempt" in "trunk".
[bertos.git] / bertos / struct / list.h
index f9dc9294a75dbf545ce07c7d233f3af38e3524ee..b970b7cf2d3355af09f9706815a854e029e1d4c1 100644 (file)
@@ -276,9 +276,24 @@ typedef struct _PriNode
 /**
  * Insert a priority node in a priority queue.
  *
- * The new node is inserted immediately before the
- * first node with lower priority or appended to
- * the tail if no such node exists.
+ * The new node is inserted immediately before the first node with the same
+ * priority or appended to the tail if no such node exists.
+ */
+#define LIST_ENQUEUE_HEAD(list, node) \
+       do { \
+               PriNode *ln; \
+               LIST_ASSERT_NOT_CONTAINS((list),(node)); \
+               FOREACH_NODE(ln, (list)) \
+                       if (ln->pri <= (node)->pri) \
+                               break; \
+               INSERT_BEFORE(&(node)->link, &ln->link); \
+       } while (0)
+
+/**
+ * Insert a priority node in a priority queue.
+ *
+ * The new node is inserted immediately before the first node with lower
+ * priority or appended to the tail if no such node exists.
  */
 #define LIST_ENQUEUE(list, node) \
        do { \