From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, RP_MATCHES_RCVD,URIBL_BLOCKED shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: spew@80x24.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id BF28D1FB0F; Fri, 24 Oct 2014 22:02:47 +0000 (UTC) From: Eric Wong To: ccan@lists.ozlabs.org Cc: david@gibson.dropbear.id.au, spew@80x24.org, Eric Wong Subject: [PATCH 4/5] list: add list_for_each_rev_off macro Date: Fri, 24 Oct 2014 22:02:31 +0000 Message-Id: <1414188152-24228-5-git-send-email-normalperson@yhbt.net> X-Mailer: git-send-email 2.1.2.332.g3e2d233 In-Reply-To: <1414188152-24228-1-git-send-email-normalperson@yhbt.net> References: <1414188152-24228-1-git-send-email-normalperson@yhbt.net> List-Id: 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 --- 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