Add FIRST/NEXT/LAST/PREV macros, analogous to sys/queue.h

This commit is contained in:
Nils O. Selåsdal
2013-11-28 23:21:56 +01:00
parent f5d918e77d
commit 44b86f2fde
+17
View File
@@ -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.