X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fstruct%2Flist.h;h=c83063547ef42d3a55403bf1e1a4be3d5904a850;hb=adde3a44787554723d12e61e5c69fca10a514c59;hp=f9dc9294a75dbf545ce07c7d233f3af38e3524ee;hpb=112e4b3e452a74564698d4b6dbc020532c200dc8;p=bertos.git diff --git a/bertos/struct/list.h b/bertos/struct/list.h index f9dc9294..c8306354 100644 --- a/bertos/struct/list.h +++ b/bertos/struct/list.h @@ -32,7 +32,6 @@ * * \brief General pourpose double-linked lists * - * \version $Id$ * \author Bernie Innocenti */ @@ -276,9 +275,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 { \