X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flist.h;h=2bec8c9e738f252332ca3b69b800bc21f704f461;hp=012dd1207329e93d8b18773eb69c5bfe740dc3c9;hb=6210e7fc31e14159627144f7409eadd3ce0d72b9;hpb=e99e38bbdcca3fe5956823bdb3d38544ccf93221 diff --git a/src/list.h b/src/list.h index 012dd1207..2bec8c9e7 100644 --- a/src/list.h +++ b/src/list.h @@ -1,4 +1,4 @@ -/*-*- Mode: C; c-basic-offset: 8 -*-*/ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ #ifndef foolisthfoo #define foolisthfoo @@ -77,7 +77,7 @@ do { \ t *_item = (item); \ assert(_item); \ - while ((_item->name##_prev) \ + while (_item->name##_prev) \ _item = _item->name##_prev; \ (head) = _item; \ } while (false) @@ -110,10 +110,19 @@ } \ } while(false) +#define LIST_JUST_US(name,item) \ + (!(item)->name##_prev && !(item)->name##_next) \ + #define LIST_FOREACH(name,i,head) \ for ((i) = (head); (i); (i) = (i)->name##_next) #define LIST_FOREACH_SAFE(name,i,n,head) \ for ((i) = (head); (i) && (((n) = (i)->name##_next), 1); (i) = (n)) +#define LIST_FOREACH_BEFORE(name,i,p) \ + for ((i) = (p)->name##_prev; (i); (i) = (i)->name##_prev) + +#define LIST_FOREACH_AFTER(name,i,p) \ + for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next) + #endif