From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alberich de megres Subject: RB tree Date: Wed, 10 Mar 2010 12:07:24 +0100 Message-ID: <12d708831003100307i2b709cf9g59c349f7a1197af9@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 To: linux-fsdevel@vger.kernel.org Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:42513 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750910Ab0CJLH1 (ORCPT ); Wed, 10 Mar 2010 06:07:27 -0500 Received: by wyb38 with SMTP id 38so38975wyb.19 for ; Wed, 10 Mar 2010 03:07:25 -0800 (PST) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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