[Fwd: [Fwd: RFC.. defining __rangeof() in cdefs.h]]
Giorgos Keramidas
keramida at ceid.upatras.gr
Thu Aug 12 16:08:16 PDT 2004
On 2004-08-11 17:44, Julian Elischer <julian at elischer.org> wrote:
> Warner suggested this should be asked here..
> Date: Wed, 11 Aug 2004 15:47:31 -0700
> To: current at freebsd.org
>
> Interresting.. not a single comment.. :-/
> Date: Mon, 09 Aug 2004 14:40:37 -0700
> To: current at 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
More information about the freebsd-arch
mailing list