dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH 0/5] new ccan/list functionality
@ 2014-10-24 22:02 Eric Wong
  2014-10-24 22:02 ` [RESEND PATCH 1/5] list: list_add_after and list_add_before functions Eric Wong
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Eric Wong @ 2014-10-24 22:02 UTC (permalink / raw)
  To: ccan; +Cc: david, spew

These are mainly for replacing some custom linked-list implementations
in the mainline Ruby VM; but should be useful for other projects.

Patches 1 and 2 are reviewed by David.

Patches 3-5 are implemented based on David's comments in
<20141006235924.GA12838@voom.redhat.com>
for my original list_for_each_rev_safe patch.

Eric Wong (5):
      list: list_add_after and list_add_before functions
      list: list_swap to exchange elements
      list: new list_for_each{,_safe}_off_dir_ macros
      list: add list_for_each_rev_off macro
      list: add list_for_each_rev_safe{,_off} macros

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RESEND PATCH 1/5] list: list_add_after and list_add_before functions
  2014-10-24 22:02 [PATCH 0/5] new ccan/list functionality Eric Wong
@ 2014-10-24 22:02 ` Eric Wong
  2014-10-24 22:02 ` [RESEND PATCH 2/5] list: list_swap to exchange elements Eric Wong
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Eric Wong @ 2014-10-24 22:02 UTC (permalink / raw)
  To: ccan; +Cc: david, spew, Eric Wong

These make it easy to add a new element before or after an
existing element in the middle of the list.

The existing list_add and list_add_tail functions are trivially
reimplemented on top of these new functions.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 ccan/list/list.h     | 68 +++++++++++++++++++++++++++++++++++++++++++++-------
 ccan/list/test/run.c | 40 ++++++++++++++++++++++++++++++-
 2 files changed, 98 insertions(+), 10 deletions(-)

diff --git a/ccan/list/list.h b/ccan/list/list.h
index cdd5eeb..5c1159f 100644
--- a/ccan/list/list.h
+++ b/ccan/list/list.h
@@ -158,6 +158,36 @@ static inline void list_node_init(struct list_node *n)
 }
 
 /**
+ * list_add_after - add an entry after an existing node in a linked list
+ * @h: the list_head to add the node to (for debugging)
+ * @p: the existing list_node to add the node after
+ * @n: the new list_node to add to the list.
+ *
+ * The existing list_node must already be a member of the list.
+ * The new list_node does not need to be initialized; it will be overwritten.
+ *
+ * Example:
+ *	struct child c1, c2, c3;
+ *	LIST_HEAD(h);
+ *
+ *	list_add_tail(&h, &c1.list);
+ *	list_add_tail(&h, &c3.list);
+ *	list_add_after(&h, &c1.list, &c2.list);
+ */
+#define list_add_after(h, p, n) list_add_after_(h, p, n, LIST_LOC)
+static inline void list_add_after_(struct list_head *h,
+				   struct list_node *p,
+				   struct list_node *n,
+				   const char *abortstr)
+{
+	n->next = p->next;
+	n->prev = p;
+	p->next->prev = n;
+	p->next = n;
+	(void)list_debug(h, abortstr);
+}
+
+/**
  * list_add - add an entry at the start of a linked list.
  * @h: the list_head to add the node to
  * @n: the list_node to add to the list.
@@ -175,10 +205,34 @@ static inline void list_add_(struct list_head *h,
 			     struct list_node *n,
 			     const char *abortstr)
 {
-	n->next = h->n.next;
-	n->prev = &h->n;
-	h->n.next->prev = n;
-	h->n.next = n;
+	list_add_after_(h, &h->n, n, abortstr);
+}
+
+/**
+ * list_add_before - add an entry before an existing node in a linked list
+ * @h: the list_head to add the node to (for debugging)
+ * @p: the existing list_node to add the node before
+ * @n: the new list_node to add to the list.
+ *
+ * The existing list_node must already be a member of the list.
+ * The new list_node does not need to be initialized; it will be overwritten.
+ *
+ * Example:
+ *	list_head_init(&h);
+ *	list_add_tail(&h, &c1.list);
+ *	list_add_tail(&h, &c3.list);
+ *	list_add_before(&h, &c3.list, &c2.list);
+ */
+#define list_add_before(h, p, n) list_add_before_(h, p, n, LIST_LOC)
+static inline void list_add_before_(struct list_head *h,
+				    struct list_node *p,
+				    struct list_node *n,
+				    const char *abortstr)
+{
+	n->next = p;
+	n->prev = p->prev;
+	p->prev->next = n;
+	p->prev = n;
 	(void)list_debug(h, abortstr);
 }
 
@@ -197,11 +251,7 @@ static inline void list_add_tail_(struct list_head *h,
 				  struct list_node *n,
 				  const char *abortstr)
 {
-	n->next = &h->n;
-	n->prev = h->n.prev;
-	h->n.prev->next = n;
-	h->n.prev = n;
-	(void)list_debug(h, abortstr);
+	list_add_before_(h, &h->n, n, abortstr);
 }
 
 /**
diff --git a/ccan/list/test/run.c b/ccan/list/test/run.c
index 88c3835..2f1acc7 100644
--- a/ccan/list/test/run.c
+++ b/ccan/list/test/run.c
@@ -25,7 +25,7 @@ int main(int argc, char *argv[])
 	opaque_t *q, *nq;
 	struct list_head opaque_list = LIST_HEAD_INIT(opaque_list);
 
-	plan_tests(70);
+	plan_tests(79);
 	/* Test LIST_HEAD, LIST_HEAD_INIT, list_empty and check_list */
 	ok1(list_empty(&static_list));
 	ok1(list_check(&static_list, NULL));
@@ -215,5 +215,43 @@ int main(int argc, char *argv[])
 	ok1(list_top(&parent.children, struct child, list) == NULL);
 	ok1(list_tail(&parent.children, struct child, list) == NULL);
 	ok1(list_pop(&parent.children, struct child, list) == NULL);
+
+	/* Test list_add_before and list_add_after */
+	list_add(&parent.children, &c1.list);
+	list_add_after(&parent.children, &c1.list, &c2.list);
+	ok1(list_check(&parent.children, "list_add_after"));
+
+	i = 0;
+	list_for_each(&parent.children, c, list) {
+		switch (i++) {
+		case 0:
+			ok1(c == &c1);
+			break;
+		case 1:
+			ok1(c == &c2);
+			break;
+		}
+	}
+	ok1(i == 2);
+
+	list_add_before(&parent.children, &c2.list, &c3.list);
+	ok1(list_check(&parent.children, "list_add_before"));
+
+	i = 0;
+	list_for_each(&parent.children, c, list) {
+		switch (i++) {
+		case 0:
+			ok1(c == &c1);
+			break;
+		case 1:
+			ok1(c == &c3);
+			break;
+		case 2:
+			ok1(c == &c2);
+			break;
+		}
+	}
+	ok1(i == 3);
+
 	return exit_status();
 }
-- 
EW


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [RESEND PATCH 2/5] list: list_swap to exchange elements
  2014-10-24 22:02 [PATCH 0/5] new ccan/list functionality Eric Wong
  2014-10-24 22:02 ` [RESEND PATCH 1/5] list: list_add_after and list_add_before functions Eric Wong
@ 2014-10-24 22:02 ` Eric Wong
  2014-10-24 22:02 ` [PATCH 3/5] list: new list_for_each{,_safe}_off_dir_ macros Eric Wong
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Eric Wong @ 2014-10-24 22:02 UTC (permalink / raw)
  To: ccan; +Cc: david, spew, Eric Wong

This allows deleting and re-inserting an element in place
of the deleted element without branching.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 ccan/list/list.h     | 33 +++++++++++++++++++++++++++++++++
 ccan/list/test/run.c | 23 +++++++++++++++++++++--
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/ccan/list/list.h b/ccan/list/list.h
index 5c1159f..983675b 100644
--- a/ccan/list/list.h
+++ b/ccan/list/list.h
@@ -369,6 +369,39 @@ static inline void list_del_from(struct list_head *h, struct list_node *n)
 }
 
 /**
+ * list_swap - swap out an entry from an (unknown) linked list for a new one.
+ * @o: the list_node to replace from the list.
+ * @n: the list_node to insert in place of the old one.
+ *
+ * Note that this leaves @o in an undefined state; it can be added to
+ * another list, but not deleted/swapped again.
+ *
+ * See also:
+ *	list_del()
+ *
+ * Example:
+ *	struct child x1, x2;
+ *	LIST_HEAD(xh);
+ *
+ *	list_add(&xh, &x1.list);
+ *	list_swap(&x1.list, &x2.list);
+ */
+#define list_swap(o, n) list_swap_(o, n, LIST_LOC)
+static inline void list_swap_(struct list_node *o,
+			      struct list_node *n,
+			      const char* abortstr)
+{
+	(void)list_debug_node(o, abortstr);
+	*n = *o;
+	n->next->prev = n;
+	n->prev->next = n;
+#ifdef CCAN_LIST_DEBUG
+	/* Catch use-after-del. */
+	o->next = o->prev = NULL;
+#endif
+}
+
+/**
  * list_entry - convert a list_node back into the structure containing it.
  * @n: the list_node
  * @type: the type of the entry
diff --git a/ccan/list/test/run.c b/ccan/list/test/run.c
index 2f1acc7..3067445 100644
--- a/ccan/list/test/run.c
+++ b/ccan/list/test/run.c
@@ -19,13 +19,13 @@ static LIST_HEAD(static_list);
 int main(int argc, char *argv[])
 {
 	struct parent parent;
-	struct child c1, c2, c3, *c, *n;
+	struct child c1, c2, c3, x1, *c, *n;
 	unsigned int i;
 	struct list_head list = LIST_HEAD_INIT(list);
 	opaque_t *q, *nq;
 	struct list_head opaque_list = LIST_HEAD_INIT(opaque_list);
 
-	plan_tests(79);
+	plan_tests(84);
 	/* Test LIST_HEAD, LIST_HEAD_INIT, list_empty and check_list */
 	ok1(list_empty(&static_list));
 	ok1(list_check(&static_list, NULL));
@@ -253,5 +253,24 @@ int main(int argc, char *argv[])
 	}
 	ok1(i == 3);
 
+	/* test list_swap */
+	list_swap(&c3.list, &x1.list);
+	ok1(list_check(&parent.children, "list_swap"));
+	i = 0;
+	list_for_each(&parent.children, c, list) {
+		switch (i++) {
+		case 0:
+			ok1(c == &c1);
+			break;
+		case 1:
+			ok1(c == &x1);
+			break;
+		case 2:
+			ok1(c == &c2);
+			break;
+		}
+	}
+	ok1(i == 3);
+
 	return exit_status();
 }
-- 
EW


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/5] list: new list_for_each{,_safe}_off_dir_ macros
  2014-10-24 22:02 [PATCH 0/5] new ccan/list functionality Eric Wong
  2014-10-24 22:02 ` [RESEND PATCH 1/5] list: list_add_after and list_add_before functions Eric Wong
  2014-10-24 22:02 ` [RESEND PATCH 2/5] list: list_swap to exchange elements Eric Wong
@ 2014-10-24 22:02 ` Eric Wong
  2014-11-03  9:14   ` David Gibson
  2014-10-24 22:02 ` [PATCH 4/5] list: add list_for_each_rev_off macro Eric Wong
  2014-10-24 22:02 ` [PATCH 5/5] list: add list_for_each_rev_safe{,_off} macros Eric Wong
  4 siblings, 1 reply; 11+ messages in thread
From: Eric Wong @ 2014-10-24 22:02 UTC (permalink / raw)
  To: ccan; +Cc: david, spew, Eric Wong

These internal iteration macros will make implementing reverse
iteration simpler.  For now, reimplement existing list_for_each_off
and list_for_each_safe_off macros on top of these macros to
prove they pass existing tests.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 ccan/list/list.h | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/ccan/list/list.h b/ccan/list/list.h
index 983675b..90989c5 100644
--- a/ccan/list/list.h
+++ b/ccan/list/list.h
@@ -653,6 +653,24 @@ static inline void list_prepend_list_(struct list_head *to,
 	list_head_init(from);
 }
 
+/* internal macros, do not use directly */
+#define list_for_each_off_dir_(h, i, off, dir)				\
+	for (i = list_node_to_off_(list_debug(h, LIST_LOC)->n.dir,	\
+				   (off));				\
+	list_node_from_off_((void *)i, (off)) != &(h)->n;		\
+	i = list_node_to_off_(list_node_from_off_((void *)i, (off))->dir, \
+			      (off)))
+
+#define list_for_each_safe_off_dir_(h, i, nxt, off, dir)		\
+	for (i = list_node_to_off_(list_debug(h, LIST_LOC)->n.dir,	\
+				   (off)),				\
+	nxt = list_node_to_off_(list_node_from_off_(i, (off))->dir,	\
+				(off));					\
+	list_node_from_off_(i, (off)) != &(h)->n;			\
+	i = nxt,							\
+	nxt = list_node_to_off_(list_node_from_off_(i, (off))->dir,	\
+				(off)))
+
 /**
  * list_for_each_off - iterate through a list of memory regions.
  * @h: the list_head
@@ -683,11 +701,7 @@ static inline void list_prepend_list_(struct list_head *to,
  *		printf("Name: %s\n", child->name);
  */
 #define list_for_each_off(h, i, off)                                    \
-	for (i = list_node_to_off_(list_debug(h, LIST_LOC)->n.next,	\
-				   (off));				\
-       list_node_from_off_((void *)i, (off)) != &(h)->n;                \
-       i = list_node_to_off_(list_node_from_off_((void *)i, (off))->next, \
-                             (off)))
+	list_for_each_off_dir_((h),(i),(off),next)
 
 /**
  * list_for_each_safe_off - iterate through a list of memory regions, maybe
@@ -706,15 +720,7 @@ static inline void list_prepend_list_(struct list_head *to,
  *		printf("Name: %s\n", child->name);
  */
 #define list_for_each_safe_off(h, i, nxt, off)                          \
-	for (i = list_node_to_off_(list_debug(h, LIST_LOC)->n.next,	\
-				   (off)),				\
-         nxt = list_node_to_off_(list_node_from_off_(i, (off))->next,   \
-                                 (off));                                \
-       list_node_from_off_(i, (off)) != &(h)->n;                        \
-       i = nxt,                                                         \
-         nxt = list_node_to_off_(list_node_from_off_(i, (off))->next,   \
-                                 (off)))
-
+	list_for_each_safe_off_dir_((h),(i),(nxt),(off),next)
 
 /* Other -off variants. */
 #define list_entry_off(n, type, off)		\
-- 
EW


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/5] list: add list_for_each_rev_off macro
  2014-10-24 22:02 [PATCH 0/5] new ccan/list functionality Eric Wong
                   ` (2 preceding siblings ...)
  2014-10-24 22:02 ` [PATCH 3/5] list: new list_for_each{,_safe}_off_dir_ macros Eric Wong
@ 2014-10-24 22:02 ` Eric Wong
  2014-11-03  9:16   ` David Gibson
  2014-10-24 22:02 ` [PATCH 5/5] list: add list_for_each_rev_safe{,_off} macros Eric Wong
  4 siblings, 1 reply; 11+ messages in thread
From: Eric Wong @ 2014-10-24 22:02 UTC (permalink / raw)
  To: ccan; +Cc: david, spew, Eric Wong

And re-implement list_for_each_rev in terms of list_for_each_rev_off
to avoid duplicating iteration logic.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 ccan/list/list.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/ccan/list/list.h b/ccan/list/list.h
index 90989c5..aaf135d 100644
--- a/ccan/list/list.h
+++ b/ccan/list/list.h
@@ -522,9 +522,7 @@ static inline const void *list_tail_(const struct list_head *h, size_t off)
  *		printf("Name: %s\n", child->name);
  */
 #define list_for_each_rev(h, i, member)					\
-	for (i = container_of_var(list_debug(h,	LIST_LOC)->n.prev, i, member); \
-	     &i->member != &(h)->n;					\
-	     i = container_of_var(i->member.prev, i, member))
+	list_for_each_rev_off(h, i, list_off_var_(i, member))
 
 /**
  * list_for_each_safe - iterate through a list, maybe during deletion
@@ -704,6 +702,17 @@ static inline void list_prepend_list_(struct list_head *to,
 	list_for_each_off_dir_((h),(i),(off),next)
 
 /**
+ * list_for_each_rev_off - iterate through a list of memory regions backwards
+ * @h: the list_head
+ * @i: the pointer to a memory region wich contains list node data.
+ * @off: offset(relative to @i) at which list node data resides.
+ *
+ * See list_for_each_off for details
+ */
+#define list_for_each_rev_off(h, i, off)                                    \
+	list_for_each_off_dir_((h),(i),(off),prev)
+
+/**
  * list_for_each_safe_off - iterate through a list of memory regions, maybe
  * during deletion
  * @h: the list_head
-- 
EW


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/5] list: add list_for_each_rev_safe{,_off} macros
  2014-10-24 22:02 [PATCH 0/5] new ccan/list functionality Eric Wong
                   ` (3 preceding siblings ...)
  2014-10-24 22:02 ` [PATCH 4/5] list: add list_for_each_rev_off macro Eric Wong
@ 2014-10-24 22:02 ` Eric Wong
  2014-11-03  9:30   ` David Gibson
  4 siblings, 1 reply; 11+ messages in thread
From: Eric Wong @ 2014-10-24 22:02 UTC (permalink / raw)
  To: ccan; +Cc: david, spew, Eric Wong

Deleting while iterating backwards will be needed in the
Ruby st_foreach_reverse_check implementation if we decide
to port Ruby's st.c to use ccan/list.

ref: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/65408

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 ccan/list/list.h     | 42 +++++++++++++++++++++++++++++++++++++++++-
 ccan/list/test/run.c | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/ccan/list/list.h b/ccan/list/list.h
index aaf135d..275442d 100644
--- a/ccan/list/list.h
+++ b/ccan/list/list.h
@@ -525,6 +525,28 @@ static inline const void *list_tail_(const struct list_head *h, size_t off)
 	list_for_each_rev_off(h, i, list_off_var_(i, member))
 
 /**
+ * list_for_each_rev_safe - iterate through a list backwards,
+ * maybe during deletion
+ * @h: the list_head
+ * @i: the structure containing the list_node
+ * @nxt: the structure containing the list_node
+ * @member: the list_node member of the structure
+ *
+ * This is a convenient wrapper to iterate @i over the entire list backwards.
+ * It's a for loop, so you can break and continue as normal.  The extra
+ * variable * @nxt is used to hold the next element, so you can delete @i
+ * from the list.
+ *
+ * Example:
+ *	struct child *next;
+ *	list_for_each_rev_safe(&parent->children, child, next, list) {
+ *		printf("Name: %s\n", child->name);
+ *	}
+ */
+#define list_for_each_rev_safe(h, i, nxt, member)			\
+	list_for_each_rev_safe_off(h, i, nxt, list_off_var_(i, member))
+
+/**
  * list_for_each_safe - iterate through a list, maybe during deletion
  * @h: the list_head
  * @i: the structure containing the list_node
@@ -536,7 +558,6 @@ static inline const void *list_tail_(const struct list_head *h, size_t off)
  * @nxt is used to hold the next element, so you can delete @i from the list.
  *
  * Example:
- *	struct child *next;
  *	list_for_each_safe(&parent->children, child, next, list) {
  *		list_del(&child->list);
  *		parent->num_children--;
@@ -731,6 +752,25 @@ static inline void list_prepend_list_(struct list_head *to,
 #define list_for_each_safe_off(h, i, nxt, off)                          \
 	list_for_each_safe_off_dir_((h),(i),(nxt),(off),next)
 
+/**
+ * list_for_each_rev_safe_off - iterate backwards through a list of
+ * memory regions, maybe during deletion
+ * @h: the list_head
+ * @i: the pointer to a memory region wich contains list node data.
+ * @nxt: the structure containing the list_node
+ * @off: offset(relative to @i) at which list node data resides.
+ *
+ * For details see `list_for_each_rev_off' and `list_for_each_rev_safe'
+ * descriptions.
+ *
+ * Example:
+ *	list_for_each_rev_safe_off(&parent->children, child,
+ *		next, offsetof(struct child, list))
+ *		printf("Name: %s\n", child->name);
+ */
+#define list_for_each_rev_safe_off(h, i, nxt, off)                      \
+	list_for_each_safe_off_dir_((h),(i),(nxt),(off),prev)
+
 /* Other -off variants. */
 #define list_entry_off(n, type, off)		\
 	((type *)list_node_from_off_((n), (off)))
diff --git a/ccan/list/test/run.c b/ccan/list/test/run.c
index 3067445..7616af6 100644
--- a/ccan/list/test/run.c
+++ b/ccan/list/test/run.c
@@ -24,8 +24,9 @@ int main(int argc, char *argv[])
 	struct list_head list = LIST_HEAD_INIT(list);
 	opaque_t *q, *nq;
 	struct list_head opaque_list = LIST_HEAD_INIT(opaque_list);
+	LIST_HEAD(rev);
 
-	plan_tests(84);
+	plan_tests(92);
 	/* Test LIST_HEAD, LIST_HEAD_INIT, list_empty and check_list */
 	ok1(list_empty(&static_list));
 	ok1(list_check(&static_list, NULL));
@@ -148,6 +149,10 @@ int main(int argc, char *argv[])
 			list_del_from(&parent.children, &c->list);
 			break;
 		}
+
+		/* prepare for list_for_each_rev_safe test */
+		list_add(&rev, &c->list);
+
 		ok1(list_check(&parent.children, NULL));
 		if (i > 2)
 			break;
@@ -155,6 +160,30 @@ int main(int argc, char *argv[])
 	ok1(i == 3);
 	ok1(list_empty(&parent.children));
 
+	/* Test list_for_each_rev_safe, list_del and list_del_from. */
+	i = 0;
+	list_for_each_rev_safe(&rev, c, n, list) {
+		switch (i++) {
+		case 0:
+			ok1(c == &c1);
+			list_del(&c->list);
+			break;
+		case 1:
+			ok1(c == &c2);
+			list_del_from(&rev, &c->list);
+			break;
+		case 2:
+			ok1(c == &c3);
+			list_del_from(&rev, &c->list);
+			break;
+		}
+		ok1(list_check(&rev, NULL));
+		if (i > 2)
+			break;
+	}
+	ok1(i == 3);
+	ok1(list_empty(&rev));
+
 	/* Test list_node_init: safe to list_del after this. */
 	list_node_init(&c->list);
 	list_del(&c->list);
-- 
EW


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] list: new list_for_each{,_safe}_off_dir_ macros
  2014-10-24 22:02 ` [PATCH 3/5] list: new list_for_each{,_safe}_off_dir_ macros Eric Wong
@ 2014-11-03  9:14   ` David Gibson
  0 siblings, 0 replies; 11+ messages in thread
From: David Gibson @ 2014-11-03  9:14 UTC (permalink / raw)
  To: Eric Wong; +Cc: ccan, spew

[-- Attachment #1: Type: text/plain, Size: 608 bytes --]

On Fri, Oct 24, 2014 at 10:02:30PM +0000, Eric Wong wrote:
> These internal iteration macros will make implementing reverse
> iteration simpler.  For now, reimplement existing list_for_each_off
> and list_for_each_safe_off macros on top of these macros to
> prove they pass existing tests.
> 
> Signed-off-by: Eric Wong <normalperson@yhbt.net>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson


[-- Attachment #2: Type: application/pgp-signature, Size: 820 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] list: add list_for_each_rev_off macro
  2014-10-24 22:02 ` [PATCH 4/5] list: add list_for_each_rev_off macro Eric Wong
@ 2014-11-03  9:16   ` David Gibson
  0 siblings, 0 replies; 11+ messages in thread
From: David Gibson @ 2014-11-03  9:16 UTC (permalink / raw)
  To: Eric Wong; +Cc: ccan, spew

[-- Attachment #1: Type: text/plain, Size: 486 bytes --]

On Fri, Oct 24, 2014 at 10:02:31PM +0000, Eric Wong wrote:
> And re-implement list_for_each_rev in terms of list_for_each_rev_off
> to avoid duplicating iteration logic.
> 
> Signed-off-by: Eric Wong <normalperson@yhbt.net>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson


[-- Attachment #2: Type: application/pgp-signature, Size: 820 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/5] list: add list_for_each_rev_safe{,_off} macros
  2014-10-24 22:02 ` [PATCH 5/5] list: add list_for_each_rev_safe{,_off} macros Eric Wong
@ 2014-11-03  9:30   ` David Gibson
  2014-12-18 19:40     ` Eric Wong
  0 siblings, 1 reply; 11+ messages in thread
From: David Gibson @ 2014-11-03  9:30 UTC (permalink / raw)
  To: Eric Wong; +Cc: ccan, spew

[-- Attachment #1: Type: text/plain, Size: 613 bytes --]

On Fri, Oct 24, 2014 at 10:02:32PM +0000, Eric Wong wrote:
> Deleting while iterating backwards will be needed in the
> Ruby st_foreach_reverse_check implementation if we decide
> to port Ruby's st.c to use ccan/list.
> 
> ref: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/65408
> 
> Signed-off-by: Eric Wong <normalperson@yhbt.net>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson


[-- Attachment #2: Type: application/pgp-signature, Size: 820 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/5] list: add list_for_each_rev_safe{,_off} macros
  2014-11-03  9:30   ` David Gibson
@ 2014-12-18 19:40     ` Eric Wong
  2015-03-30  6:27       ` [ccan] [PATCH 5/5] list: add list_for_each_rev_safe{, _off} macros Rusty Russell
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Wong @ 2014-12-18 19:40 UTC (permalink / raw)
  To: David Gibson; +Cc: ccan, spew

David Gibson <david@gibson.dropbear.id.au> wrote:
> On Fri, Oct 24, 2014 at 10:02:32PM +0000, Eric Wong wrote:
> > Deleting while iterating backwards will be needed in the
> > Ruby st_foreach_reverse_check implementation if we decide
> > to port Ruby's st.c to use ccan/list.
> > 
> > ref: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/65408
> > 
> > Signed-off-by: Eric Wong <normalperson@yhbt.net>
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

Thanks, anything else needed on this series to get applied?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ccan] [PATCH 5/5] list: add list_for_each_rev_safe{, _off} macros
  2014-12-18 19:40     ` Eric Wong
@ 2015-03-30  6:27       ` Rusty Russell
  0 siblings, 0 replies; 11+ messages in thread
From: Rusty Russell @ 2015-03-30  6:27 UTC (permalink / raw)
  To: Eric Wong, David Gibson; +Cc: ccan, spew

Eric Wong <normalperson@yhbt.net> writes:
> David Gibson <david@gibson.dropbear.id.au> wrote:
>> On Fri, Oct 24, 2014 at 10:02:32PM +0000, Eric Wong wrote:
>> > Deleting while iterating backwards will be needed in the
>> > Ruby st_foreach_reverse_check implementation if we decide
>> > to port Ruby's st.c to use ccan/list.
>> > 
>> > ref: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/65408
>> > 
>> > Signed-off-by: Eric Wong <normalperson@yhbt.net>
>> 
>> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>
> Thanks, anything else needed on this series to get applied?

Just a ccan maintainer who is not asleep at the wheel :(

I have applied them!

Thanks for these!
Rusty.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-03-30 12:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-24 22:02 [PATCH 0/5] new ccan/list functionality Eric Wong
2014-10-24 22:02 ` [RESEND PATCH 1/5] list: list_add_after and list_add_before functions Eric Wong
2014-10-24 22:02 ` [RESEND PATCH 2/5] list: list_swap to exchange elements Eric Wong
2014-10-24 22:02 ` [PATCH 3/5] list: new list_for_each{,_safe}_off_dir_ macros Eric Wong
2014-11-03  9:14   ` David Gibson
2014-10-24 22:02 ` [PATCH 4/5] list: add list_for_each_rev_off macro Eric Wong
2014-11-03  9:16   ` David Gibson
2014-10-24 22:02 ` [PATCH 5/5] list: add list_for_each_rev_safe{,_off} macros Eric Wong
2014-11-03  9:30   ` David Gibson
2014-12-18 19:40     ` Eric Wong
2015-03-30  6:27       ` [ccan] [PATCH 5/5] list: add list_for_each_rev_safe{, _off} macros Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).