From: Alberich de megres <alberich2k5@gmail.com>
To: linux-fsdevel@vger.kernel.org
Subject: RB tree
Date: Wed, 10 Mar 2010 12:07:24 +0100 [thread overview]
Message-ID: <12d708831003100307i2b709cf9g59c349f7a1197af9@mail.gmail.com> (raw)
Hi!
I know this could be a stupid question, but taking a look at rbtree
kernel imprelantacion used in ext3 fs, I understand what lines do, but
i could not see what the use it (i'm not telling it is pointless, only
that i didn't understand why its doing what its doing)
I can see it's zeroing last 2 bits on the rb_parent_color:
#define rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~3))
We are getting only last bit:
#define rb_color(r) ((r)->rb_parent_color & 1)
Setting or clearing the last bit:
#define rb_set_red(r) do { (r)->rb_parent_color &= ~1; } while (0)
#define rb_set_black(r) do { (r)->rb_parent_color |= 1; } while (0)
And here, comes my trouble:
static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
{
rb->rb_parent_color = (rb->rb_parent_color & 3) | (unsigned long)p;
}
static inline void rb_set_color(struct rb_node *rb, int color)
{
rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
}
we are aligning the pointer address??
Thanks for the patience!!
Alberich
next reply other threads:[~2010-03-10 11:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-10 11:07 Alberich de megres [this message]
2010-03-10 18:06 ` RB tree Wendy Cheng
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=12d708831003100307i2b709cf9g59c349f7a1197af9@mail.gmail.com \
--to=alberich2k5@gmail.com \
--cc=linux-fsdevel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).