[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.1103181041230.4087@dhcp-27-109.brq.redhat.com>
Date: Fri, 18 Mar 2011 10:46:13 +0100 (CET)
From: Lukas Czerner <lczerner@...hat.com>
To: Andreas Dilger <adilger@...ger.ca>
cc: Lukas Czerner <lczerner@...hat.com>, linux-ext4@...r.kernel.org,
tytso@....edu, sandeen@...hat.com
Subject: Re: [PATCH 1/4 v2] e2fsprogs: Add rbtree library
On Thu, 17 Mar 2011, Andreas Dilger wrote:
> On 2011-03-17, at 12:50 PM, Lukas Czerner wrote:
> > +#undef offsetof
> > +#ifdef __compiler_offsetof
> > +#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
> > +#else
> > +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
> > +#endif
>
> This may as well go into a more common header like lib/ext2fs/ext2fs.h, since I see offsetof() is #defined 5 separate times in the e2fsprogs code already.
>
> > +#define container_of(ptr, type, member) ({ \
> > + const typeof( ((type *)0)->member ) *__mptr = (ptr); \
> > + (type *)( (char *)__mptr - offsetof(type,member) );})
>
> Same.
>
> > +#define rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~3))
> > +#define rb_color(r) ((r)->rb_parent_color & 1)
> > +#define rb_is_red(r) (!rb_color(r))
> > +#define rb_is_black(r) rb_color(r)
> > +#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)
> > +
> > +#define RB_ROOT (struct rb_root) { NULL, }
> > +#define rb_entry(ptr, type, member) container_of(ptr, type, member)
>
> The indenting here is a bit broken, but I see it is the same in the upstream kernel code, so it probably shouldn't be changed just for e2fsprogs.
>
>
> Cheers, Andreas
>
Hi Andreas,
thank you for the review! You're right I'll move those macros into
lib/ext2fs/ext2fs.h
Thanks!
-Lukas
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists