Subject: CIRCLEQ_NEXT/PREV
To: None <tech-userlevel@netbsd.org>
From: Antti Kantee <pooka@cs.hut.fi>
List: tech-userlevel
Date: 12/15/2005 15:01:29
The intended usage of CIRCLEQ_NEXT/PREV goes totally against my intuition,
as the name implies that I can go around in circles with it.

It is probably a bit too late to do anything about those macros, but
I'd like to add two new ones, which actually make me drive in circles:

+#define        CIRCLEQ_LOOP_NEXT(head, elm, field)                     \
+       (((elm)->field.cqe_next == (void *)(head))                      \
+           ? ((head)->cqh_first)                                       \
+           : (elm->field.cqe_next))
+#define        CIRCLEQ_LOOP_PREV(head, elm, field)                     \
+       (((elm)->field.cqe_prev == (void *)(head))                      \
+           ? ((head)->cqh_last)                                        \
+           : (elm->field.cqe_prev))

Any objections (except for the names, which will no doubt create the
bulk of the discussion)?

-- 
Antti Kantee <pooka@iki.fi>                     Of course he runs NetBSD
http://www.iki.fi/pooka/                          http://www.NetBSD.org/
    "la qualité la plus indispensable du cuisinier est l'exactitude"