]> sourceware.org Git - dm.git/commitdiff
Resync list.h with LVM2.
authorAlasdair Kergon <agk@redhat.com>
Thu, 22 Sep 2005 12:06:34 +0000 (12:06 +0000)
committerAlasdair Kergon <agk@redhat.com>
Thu, 22 Sep 2005 12:06:34 +0000 (12:06 +0000)
WHATS_NEW
include/list.h

index 0f1aede6c69b921df82ea9493f8941e591ff45d6..c35bdb52a1e64d67f01368343dfabd8d8ec58165 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 1.01.05 -
 =============================
+  Resync list.h with LVM2.
   Remember increased buffer size and use for subsequent calls.
   On 'buffer full' condition, double buffer size and repeat ioctl.
   Fix termination of getopt_long() option array.
index 1ec8c73cc1ff336c7b7338a44f9d349ea52ae34b..11765ec9727bb70d8d763b88a5f4c6881bd5e5fa 100644 (file)
@@ -104,6 +104,22 @@ static inline int list_end(struct list *head, struct list *elem)
        return elem->n == head;
 }
 
+/*
+ * Return first element of the list or NULL if empty
+ */
+static inline struct list *list_first(struct list *head)
+{
+       return (list_empty(head) ? NULL : head->n);
+}
+
+/*
+ * Return last element of the list or NULL if empty
+ */
+static inline struct list *list_last(struct list *head)
+{
+       return (list_empty(head) ? NULL : head->p);
+}
+
 /*
  * Return the previous element of the list, or NULL if we've reached the start.
  */
@@ -187,6 +203,25 @@ static inline struct list *list_next(struct list *head, struct list *elem)
  */
 #define list_iterate_items(v, head) list_iterate_items_gen(v, (head), list)
 
+/*
+ * Walk a list backwards, setting 'v' in turn to the containing structure 
+ * of each item.
+ * The containing structure should be the same type as 'v'.
+ * The 'struct list' variable within the containing structure is 'field'.
+ */
+#define list_iterate_back_items_gen(v, head, field) \
+       for (v = list_struct_base((head)->p, typeof(*v), field); \
+            &v->field != (head); \
+            v = list_struct_base(v->field.p, typeof(*v), field))
+
+/*
+ * Walk a list backwards, setting 'v' in turn to the containing structure 
+ * of each item.
+ * The containing structure should be the same type as 'v'.
+ * The list should be 'struct list list' within the containing structure.
+ */
+#define list_iterate_back_items(v, head) list_iterate_back_items_gen(v, (head), list)
+
 /*
  * Return the number of elements in a list by walking it.
  */
This page took 0.029302 seconds and 5 git commands to generate.