From owner-freebsd-arch@FreeBSD.ORG Tue May 8 20:58:53 2007 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8589316A402; Tue, 8 May 2007 20:58:53 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.freebsd.org (Postfix) with ESMTP id 2EDE813C469; Tue, 8 May 2007 20:58:52 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id l48Kwfqq086157; Tue, 8 May 2007 16:58:42 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Hans Petter Selasky Date: Tue, 8 May 2007 16:58:37 -0400 User-Agent: KMail/1.9.6 References: <200705051617.34162.hselasky@c2i.net> <4640C52E.7010209@elischer.org> <200705082100.51354.hselasky@c2i.net> In-Reply-To: <200705082100.51354.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200705081658.38171.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Tue, 08 May 2007 16:58:42 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/3222/Tue May 8 11:43:01 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Giorgos Keramidas , Julian Elischer , freebsd-arch@freebsd.org Subject: Re: Missing LIST_PREV() ? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2007 20:58:53 -0000 On Tuesday 08 May 2007 03:00:51 pm Hans Petter Selasky wrote: > On Tuesday 08 May 2007 20:45, Julian Elischer wrote: > > John Baldwin wrote: > > > On Monday 07 May 2007 04:25:18 pm Giorgos Keramidas wrote: > > >> with other compilers. > > > > > > This can be fixed by passing the type as an argument which is what > > > TAILQ_PREV() does: > > > > > > #define TAILQ_PREV(elm, headname, field) = =20 \ > > > (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) > > > > > > I'm not sure how portable offsetof() would be though. In general if = you > > > want this feature, you should just use a TAILQ though. TAILQ_ENTRY()= is > > > the same size as a LIST_ENTRY(), it just adds one more pointer to the > > > HEAD structure. It is also specifically designed to make TAILQ_PREV() > > > work w/o needing the offsetof() hack. > > > > I agree with this.. that's why we have the different types. > > The suggested change in ingenious but I don't know how portable it is.. >=20 > I suggested the following at hacker's: >=20 > #define LIST_PREV(head,elm,field,type) \ > =A0(((elm) =3D=3D LIST_FIRST(head)) ? ((struct type *)0) : \ > =A0 ((struct type *)(((uint8_t *)((elm)->field.le_prev)) - \ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0((uint8_t *)&LIST_NEXT((struct typ= e *)0,field))))) >=20 > What do you think? Just use a TAILQ, that's what it is there for. =2D-=20 John Baldwin