chiark / gitweb /
build-sys: add a makefile target to run all tests through valgrind
[elogind.git] / src / shared / list.h
index 9a491b990efe0f024d703c23f7eb9887ceee20c9..476757460aa6145c55ccc2873f016d70862582f0 100644 (file)
@@ -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.
@@ -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);                                      \
 #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))