Hans Petter Selasky
2007-05-06 11:04:04 UTC
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
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