Re: [Fwd: [Fwd: RFC.. defining __rangeof() in cdefs.h]]

From: Giorgos Keramidas (keramida_at_ceid.upatras.gr)
Date: 08/13/04

  • Next message: Francois Tigeot: "Re: NO_YP_LIBC patch - please test/review"
    Date: Fri, 13 Aug 2004 02:06:21 +0300
    To: Julian Elischer <julian@elischer.org>
    
    

    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

    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  • Next message: Francois Tigeot: "Re: NO_YP_LIBC patch - please test/review"