Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 May 2007 16:17:34 +0200
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        freebsd-arch@freebsd.org
Subject:   Missing LIST_PREV() ?
Message-ID:  <200705051617.34162.hselasky@c2i.net>

next in thread | raw e-mail | index | archive | help
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?

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705051617.34162.hselasky>