From 44b86f2fde37acb4a35fc019fc26a3ae340e3387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Thu, 28 Nov 2013 23:21:56 +0100 Subject: [PATCH] Add FIRST/NEXT/LAST/PREV macros, analogous to sys/queue.h --- include/ucore/tailq.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/ucore/tailq.h b/include/ucore/tailq.h index 3a4acda..f8e82f4 100644 --- a/include/ucore/tailq.h +++ b/include/ucore/tailq.h @@ -124,6 +124,23 @@ static UC_INLINE void uc_tailq_move_tail(struct TailQ *entry, struct TailQ *head uc_taiq_insert(entry, head->prev, head); } +//FIRST/NEXT/LAST/PREV macros similar to sys/queue.h +//Note that unlike the standard TAILQ, you have to check +// == head instead of == NULL to determine if the tailq entry +// exists + +#define UC_TAILQ_FIRST(head)\ +((head)->next) + +#define UC_TAILQ_NEXT(entry)\ +((entry)->next) + +#define UC_TAILQ_LAST(head)\ +((head)->prev) + +#define UC_TAILQ_PREV(entry)\ +((entry)->prev) + /** Iterate over a tailq. The tailq cannot be altered while iterating. * * @param entry a struct TailQ* to which each element is assigned.