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=2bec8c9e738f252332ca3b69b800bc21f704f461;hb=51d122af23533b0b8318911c4fc8b128ad8eafb7;hpb=771f19c06a9dbe19e4c3e532d901734f4b3b3a2b diff --git a/src/shared/list.h b/src/shared/list.h index 2bec8c9e7..476757460 100644 --- a/src/shared/list.h +++ b/src/shared/list.h @@ -1,7 +1,6 @@ /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ -#ifndef foolisthfoo -#define foolisthfoo +#pragma once /*** This file is part of systemd. @@ -9,16 +8,16 @@ Copyright 2010 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -82,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); \ @@ -125,4 +124,9 @@ #define LIST_FOREACH_AFTER(name,i,p) \ for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next) -#endif +/* 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))