RB tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux