Date: Thu, 4 Jan 2001 15:52:47 -0800 From: Alfred Perlstein <bright@wintelcom.net> To: Tony Finch <dot@dotat.at> Cc: arch@FreeBSD.ORG Subject: Re: Reinstatement of CIRCLEQ Message-ID: <20010104155247.G292@fw.wintelcom.net> In-Reply-To: <20010104154404.F292@fw.wintelcom.net>; from bright@wintelcom.net on Thu, Jan 04, 2001 at 03:44:04PM -0800 References: <20010104001943.T292@fw.wintelcom.net> <200101041708.JAA05731@beastie.mckusick.com> <20010104222519.Y2140@hand.dotat.at> <20010104154404.F292@fw.wintelcom.net>
next in thread | previous in thread | raw e-mail | index | archive | help
* Alfred Perlstein <bright@wintelcom.net> [010104 15:44] wrote:
> * Tony Finch <dot@dotat.at> [010104 14:25] wrote:
> > Kirk McKusick <mckusick@mckusick.com> wrote:
> > > From: Alfred Perlstein <bright@wintelcom.net>
> > >
> > > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010104155247.G292>
