Date: Fri, 13 Aug 2004 02:06:21 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Julian Elischer <julian@elischer.org> Cc: arch@freebsd.org Subject: Re: [Fwd: [Fwd: RFC.. defining __rangeof() in cdefs.h]] Message-ID: <20040812230620.GA7173@gothmog.gr> In-Reply-To: <411ABD8A.70405@elischer.org> References: <411ABD8A.70405@elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2004-08-11 17:44, Julian Elischer <julian@elischer.org> wrote: > Warner suggested this should be asked here.. > Date: Wed, 11 Aug 2004 15:47:31 -0700 > To: current@freebsd.org > > Interresting.. not a single comment.. :-/ > Date: Mon, 09 Aug 2004 14:40:37 -0700 > To: current@freebsd.org > > I'm considdereing adding: > > --- sys/cdefs.h 28 Jul 2004 07:03:42 -0000 1.83 > +++ sys/cdefs.h 9 Aug 2004 21:36:41 -0000 > @@ -241,6 +241,8 @@ > * require it. > */ > #define __offsetof(type, field) ((size_t)(&((type *)0)->field)) > +#define __rangeof(type, start, end) \ > + (__offsetof(type, end) - __offsetof(type, start)) > it is used in several places. most importantly in fork1() > > and it is defined in several files (*).. we should probably just have > one copy... Bearing in mind that I'm not really very acquainted with the internals of <cdefs.h> IMHO this is ok, since __rangeof() starts with underscores, which clearly sets it into the implementation- specific part of the namespace. If it simplifies things in the source tree and the people from -standards don't object to it, I think it's fine :-) There are now 6 different places where RANGEOF() is defined: src/sys/kern/kern_fork.c src/sys/kern/kern_proc.c src/sys/kern/kern_thr.c src/sys/kern/kern_thread.c src/sys/kern/kern_kse.c src/sys/vm/vm_glue.c All these definitions are identical, if one ignores whitespace, so moving the definition to a single place is a Good Thing(TM). It might even be possible to remove some of these (re)definitions. For instance, kern_proc.c and kern_thread.c define RANGEOF() but AFAICT they never actually use this macro. - Giorgos
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040812230620.GA7173>