Date: Wed, 19 Nov 2014 16:28:41 +0800 From: Dennis Ferguson <dennis.c.fergu...@gmail.com>
On 19 Nov, 2014, at 01:54 , Taylor R Campbell <campbell+netbsd-tech-k...@mumble.net> wrote: > What type pun is that? I don't see it. I think this one: #define TAILQ_LAST(head, headname) \ (*(((struct headname *)((head)->tqh_last))->tqh_last)) #define TAILQ_PREV(elm, headname, field) \ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) Pooh. Fortunately, it applies only to reverse iteration, which most tailq users don't rely on. Perhaps it's time to invent a new API where you have to declare the queue type up front -- both TAILQ and CIRCLEQ use the same physical structure for the head and entry, so if we had a struct tag declared up front they could both use that. Something like: BIDIQ_TYPE(frobq, frob); /* * struct frob; * struct frobq { struct frob *bqh_first; struct frob **bqh_last; }; */ BIDIQ_HEAD(frobq, frob_head); /* struct frob_head { struct frobq q; }; */ struct frob_head the_frobs = BIDIQ_HEAD_INITIALIZER(&the_frobs); struct frob { ... BIDIQ_ENTRY(frobq) f_entry; /* struct frobq f_entry; */ ... };