From owner-freebsd-arch Thu Jan 4 15:52:58 2001 From owner-freebsd-arch@FreeBSD.ORG Thu Jan 4 15:52:55 2001 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id B39F937B400 for ; Thu, 4 Jan 2001 15:52:55 -0800 (PST) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f04Nqli13376; Thu, 4 Jan 2001 15:52:47 -0800 (PST) Date: Thu, 4 Jan 2001 15:52:47 -0800 From: Alfred Perlstein To: Tony Finch Cc: arch@FreeBSD.ORG Subject: Re: Reinstatement of CIRCLEQ Message-ID: <20010104155247.G292@fw.wintelcom.net> References: <20010104001943.T292@fw.wintelcom.net> <200101041708.JAA05731@beastie.mckusick.com> <20010104222519.Y2140@hand.dotat.at> <20010104154404.F292@fw.wintelcom.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010104154404.F292@fw.wintelcom.net>; from bright@wintelcom.net on Thu, Jan 04, 2001 at 03:44:04PM -0800 Sender: bright@fw.wintelcom.net Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Alfred Perlstein [010104 15:44] wrote: > * Tony Finch [010104 14:25] wrote: > > Kirk McKusick wrote: > > > From: Alfred Perlstein > > > > > > You're right, I'm wondering though, would it be possible > > > to change TAILQ_PREV(elm, headname, field) to TAILQ_PREV(elm, > > > field) by using the offset of 'field' into the struct? > > > You could subtract the offset of 'field' from the tqe_prev > > > of the next struct right? > > > > > >You are correct that your suggested change is exactly the > > >unportability/headache that I am trying to avoid. > > > > The Apache Group needed a linked list structure that would allow > > insertions before and after a given element without knowing the > > address of the list header. Although I wanted to use sys/queue.h it > > didn't quite have that functionality so I wrote some "ring" macros > > based on code by Dean Gaudet. > > Why not just use "LIST" then? Oh, actually for TAILQ one doesn't need the listhead, just a dummy struct declaration: TAILQ_HEAD(wizbangheadp, wizbang); which expands to this: struct wazbangheadp { struct wizbang *tqh_first; struct wizbang **tqh_last; } TAILQ_PREV then just needs these args: TAILQ_PREV(&mywizbang, -> wazbangheadp <-, field); ---------------------------^^^ just the struct name. Yes, it's icky and it's C's fault for not having "typeof()" in the standard. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message