X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Flist.h;h=2939216adb60ef0aa43015421d3c9631de206a6e;hb=5c3072eab6d2e11d89452987b017541d4654ac05;hp=f0458b54e24d0d5235aa736428c12e9dfa6c0d60;hpb=502f1733e320b1339beafa949a41db3027c46ec6;p=elogind.git diff --git a/src/shared/list.h b/src/shared/list.h index f0458b54e..2939216ad 100644 --- a/src/shared/list.h +++ b/src/shared/list.h @@ -138,6 +138,18 @@ #define LIST_FOREACH_AFTER(name,i,p) \ for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next) +/* Iterate through all the members of the list p is included in, but skip over p */ +#define LIST_FOREACH_OTHERS(name,i,p) \ + for (({ \ + (i) = (p); \ + while ((i) && (i)->name##_prev) \ + (i) = (i)->name##_prev; \ + if ((i) == (p)) \ + (i) = (p)->name##_next; \ + }); \ + (i); \ + (i) = (i)->name##_next == (p) ? (p)->name##_next : (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) \