public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Ingo Molnar <mingo@elte.hu>, Frederic Weisbecker <fweisbec@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: [rfc -tip] lib,rb-tree - introduce rb_for_each helper
Date: Sun, 12 Jul 2009 02:00:09 +0400	[thread overview]
Message-ID: <20090711220009.GA16028@lenovo> (raw)

perftools already use a number of opencoded
for() iterators over rbtree. The patch introduce
rb_for_each helper for this purpose.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---

The real conversion for this macro usage should be
done later.

Also I think having rb_for_each_entry for being used
with container_of inbetween could be convinient as
well.

Anyway if we don't need such a helper -- just drop
the patch.

 include/linux/rbtree.h |    3 +++
 1 file changed, 3 insertions(+)

Index: linux-2.6.git/include/linux/rbtree.h
=====================================================================
--- linux-2.6.git.orig/include/linux/rbtree.h
+++ linux-2.6.git/include/linux/rbtree.h
@@ -145,6 +145,9 @@ extern struct rb_node *rb_prev(const str
 extern struct rb_node *rb_first(const struct rb_root *);
 extern struct rb_node *rb_last(const struct rb_root *);
 
+#define rb_for_each(nd, root) \
+	for (nd = rb_first((root)); nd; nd = rb_next(nd))
+
 /* Fast replacement of a single node without remove/rebalance/add/rebalance */
 extern void rb_replace_node(struct rb_node *victim, struct rb_node *new, 
 			    struct rb_root *root);

             reply	other threads:[~2009-07-11 22:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-11 22:00 Cyrill Gorcunov [this message]
2009-07-11 22:29 ` [rfc -tip] lib,rb-tree - introduce rb_for_each helper Frederic Weisbecker
2009-07-11 22:32   ` Frederic Weisbecker
2009-07-12  5:39     ` Cyrill Gorcunov
2009-07-12 13:20   ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090711220009.GA16028@lenovo \
    --to=gorcunov@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox