Date: Mon, 7 May 2007 23:20:34 +0300 From: Giorgos Keramidas <keramida@freebsd.org> To: Hans Petter Selasky <hselasky@c2i.net> Cc: freebsd-arch@freebsd.org Subject: Re: Missing LIST_PREV() ? Message-ID: <20070507202034.GA80846@kobe.laptop> In-Reply-To: <200705051617.34162.hselasky@c2i.net> References: <200705051617.34162.hselasky@c2i.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2007-05-05 16:17, Hans Petter Selasky <hselasky@c2i.net> wrote: > Hi, > > Why should LISTs only be forward traversable? The following piece of code make > lists backward traversable: > > /sys/sys/queue.h: > > +#define LIST_PREV(head,elm,field) \ > + (((elm) == LIST_FIRST(head)) ? ((__typeof(elm))0) : \ > + ((__typeof(elm))(((uint8_t *)((elm)->field.le_prev)) - \ > + ((uint8_t *)&LIST_NEXT((__typeof(elm))0,field))))) > > Any comments? 1. The use of (uint8_t *) casts is relatively ugly. 2. What does LIST_PREV give us that cannot be done with TAILQ_PREV() already?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070507202034.GA80846>