summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2011-03-15 01:53:42 +0000
committerAnand Avati <avati@gluster.com>2011-04-11 01:37:38 -0700
commitd473623668f91303287bfe539709a3b7f4a654a7 (patch)
treefc57606eae5a0a17b4266fc557fb48864a36db83 /libglusterfs
parent4248b4e501abd647e337328944778b447dc5a34d (diff)
core: Add list_append_init
To append to end of list, as compared to list_splice_init which prepends. Signed-off-by: Shehjar Tikoo <shehjart@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2491 ([glusterfs-3.1.3qa4]: iozone fails due to data corruption) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2491
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/list.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/libglusterfs/src/list.h b/libglusterfs/src/list.h
index d4851dfec..9c2b7720b 100644
--- a/libglusterfs/src/list.h
+++ b/libglusterfs/src/list.h
@@ -120,6 +120,7 @@ list_splice (struct list_head *list, struct list_head *head)
}
+/* Splice moves @list to the head of the list at @head. */
static inline void
list_splice_init (struct list_head *list, struct list_head *head)
{
@@ -131,6 +132,38 @@ list_splice_init (struct list_head *list, struct list_head *head)
}
+static inline void
+__list_append (struct list_head *list, struct list_head *head)
+{
+ (head->prev)->next = (list->next);
+ (list->next)->prev = (head->prev);
+ (head->prev) = (list->prev);
+ (list->prev)->next = head;
+}
+
+
+static inline void
+list_append (struct list_head *list, struct list_head *head)
+{
+ if (list_empty (list))
+ return;
+
+ __list_append (list, head);
+}
+
+
+/* Append moves @list to the end of @head */
+static inline void
+list_append_init (struct list_head *list, struct list_head *head)
+{
+ if (list_empty (list))
+ return;
+
+ __list_append (list, head);
+ INIT_LIST_HEAD (list);
+}
+
+
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))