From owner-freebsd-arch@FreeBSD.ORG Thu Aug 12 23:08:16 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 13B0616A4CE for ; Thu, 12 Aug 2004 23:08:16 +0000 (GMT) Received: from kane.otenet.gr (kane.otenet.gr [195.170.0.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7A75643D41 for ; Thu, 12 Aug 2004 23:08:14 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-b147.otenet.gr [212.205.244.155]) i7CN7ciJ012185; Fri, 13 Aug 2004 02:07:50 +0300 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.1/8.13.1) with ESMTP id i7CN6Scc007269; Fri, 13 Aug 2004 02:06:28 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.13.1/8.13.1/Submit) id i7CN6L4R007268; Fri, 13 Aug 2004 02:06:21 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 13 Aug 2004 02:06:21 +0300 From: Giorgos Keramidas To: Julian Elischer Message-ID: <20040812230620.GA7173@gothmog.gr> References: <411ABD8A.70405@elischer.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <411ABD8A.70405@elischer.org> cc: arch@freebsd.org Subject: Re: [Fwd: [Fwd: RFC.. defining __rangeof() in cdefs.h]] X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2004 23:08:16 -0000 On 2004-08-11 17:44, Julian Elischer 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 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