From: Jeff Layton Date: Thu, 30 Apr 2015 11:50:05 +0000 (-0400) Subject: urcu: add cds_list_for_each_entry_safe_from macro X-Git-Tag: v0.9.0~59 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=16d8b5dfd6b482bedd99d796a4f70f61df3fb504;p=urcu.git urcu: add cds_list_for_each_entry_safe_from macro Same as cds_list_for_each_entry_safe, but starts at an arbitrary point within the list instead of at the head. Signed-off-by: Jeff Layton Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu/list.h b/urcu/list.h index b4962b4..4aaf869 100644 --- a/urcu/list.h +++ b/urcu/list.h @@ -171,6 +171,15 @@ void cds_list_splice(struct cds_list_head *add, struct cds_list_head *head) &pos->member != (head); \ pos = p, p = cds_list_entry(pos->member.next, __typeof__(*pos), member)) +/* + * Same as cds_list_for_each_entry_safe, but starts from "pos" which should + * point to an entry within the list. + */ +#define cds_list_for_each_entry_safe_from(pos, p, head, member) \ + for (p = cds_list_entry(pos->member.next, __typeof__(*pos), member); \ + &pos->member != (head); \ + pos = p, p = cds_list_entry(pos->member.next, __typeof__(*pos), member)) + static inline int cds_list_empty(struct cds_list_head *head) {