|
|
|
@ -119,13 +119,23 @@ void clist_del(struct clist *node);
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the next entry in a clist.
|
|
|
|
|
*
|
|
|
|
|
* @param entry The `struct *` embedding a clist to get the sccessor of
|
|
|
|
|
* @param entry The `struct *` embedding a clist to get the successor of
|
|
|
|
|
* @param member Name of the `struct clist` embedded within the entry
|
|
|
|
|
* @returns The next `struct *` in the list
|
|
|
|
|
*/
|
|
|
|
|
#define clist_next_entry(entry, member) \
|
|
|
|
|
clist_entry((entry)->member.next, typeof(*(entry)), member)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the previous entry in a clist.
|
|
|
|
|
*
|
|
|
|
|
* @param entry the `struct *` embedding a clist to the the predecessor of
|
|
|
|
|
* @param emember Name of the `struct clist` embedded within the entry
|
|
|
|
|
* @returns The previous `struct *` in the list
|
|
|
|
|
*/
|
|
|
|
|
#define clist_prev_entry(entry, member) \
|
|
|
|
|
clist_entry((entry)->member.prev, typeof(*(entry)), member)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Iterate over each entry within a list.
|
|
|
|
|
*
|
|
|
|
@ -134,10 +144,46 @@ void clist_del(struct clist *node);
|
|
|
|
|
* @param member Name of the `struct clist` within the embedding structure
|
|
|
|
|
*/
|
|
|
|
|
#define clist_foreach_entry(head, cursor, member) \
|
|
|
|
|
for ((cursor) = clist_first_entry(head, typeof((*cursor)), member); \
|
|
|
|
|
for ((cursor) = clist_first_entry(head, typeof(*(cursor)), member); \
|
|
|
|
|
&(cursor)->member != (head); \
|
|
|
|
|
(cursor) = clist_next_entry(cursor, member))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Continue iterating over each entry within a clist.
|
|
|
|
|
*
|
|
|
|
|
* @param head The `struct clist *` that is the head node in the list
|
|
|
|
|
* @param cursor The `struct *` list entry from which to continue
|
|
|
|
|
* @param member Name of the `struct clist` within the embedding structure
|
|
|
|
|
*/
|
|
|
|
|
#define clist_foreach_entry_continue(head, cursor, member) \
|
|
|
|
|
for ((cursor) = clist_next_entry(cursor, member); \
|
|
|
|
|
&(cursor)->member != (head); \
|
|
|
|
|
(cursor) = clist_next_entry(cursor, member))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Iterate over a clist in reverse order.
|
|
|
|
|
*
|
|
|
|
|
* @param head The `struct clist *` that is the head node in the list
|
|
|
|
|
* @param cursor A `struct *` the list nodes are embedded in to use as a cursor
|
|
|
|
|
* @param member Name of the `struct clist` within the embedding structure
|
|
|
|
|
*/
|
|
|
|
|
#define clist_foreach_entry_rev(head, cursor, member) \
|
|
|
|
|
for ((cursor) = clist_last_entry(head, typeof(*(cursor)), member); \
|
|
|
|
|
&(cursor)->member != (head); \
|
|
|
|
|
(cursor) = clist_prev_entry(cursor, member))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Continue iterating over a clist in reverse order.
|
|
|
|
|
*
|
|
|
|
|
* @param head The `struct clist *` that is the head node in the list
|
|
|
|
|
* @param cursor The `struct *` list entry from which to continue
|
|
|
|
|
* @param member Name of the `struct clist` within the embedding structure
|
|
|
|
|
*/
|
|
|
|
|
#define clist_foreach_entry_rev_continue(head, cursor, member) \
|
|
|
|
|
for ((cursor) = clist_prev_entry(cursor, member); \
|
|
|
|
|
&(cursor)->member != (head); \
|
|
|
|
|
(cursor) = clist_prev_entry(cursor, member))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Iterate over each entry within a list, this is safe from element removal.
|
|
|
|
|
*
|
|
|
|
|