X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Flist.h;h=476757460aa6145c55ccc2873f016d70862582f0;hp=47f275a019403c873d0d52341f7ab93fdb120d48;hb=51d122af23533b0b8318911c4fc8b128ad8eafb7;hpb=f274ece0f76b5709408821e317e87aef76123db6 diff --git a/src/shared/list.h b/src/shared/list.h index 47f275a01..476757460 100644 --- a/src/shared/list.h +++ b/src/shared/list.h @@ -81,7 +81,7 @@ (head) = _item; \ } while (false) -/* Find the head of the list */ +/* Find the tail of the list */ #define LIST_FIND_TAIL(t,name,item,tail) \ do { \ t *_item = (item); \ @@ -123,3 +123,10 @@ #define LIST_FOREACH_AFTER(name,i,p) \ for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next) + +/* Loop starting from p->next until p->prev. + p can be adjusted meanwhile. */ +#define LIST_LOOP_BUT_ONE(name,i,head,p) \ + for ((i) = (p)->name##_next ? (p)->name##_next : (head); \ + (i) != (p); \ + (i) = (i)->name##_next ? (i)->name##_next : (head))