[lttng-dev] [urcu commit] list: implement cds_list_for_each_safe()

Paul E. McKenney paulmck at linux.vnet.ibm.com
Wed Mar 13 12:46:18 EDT 2013


On Wed, Mar 13, 2013 at 12:30:30PM -0400, Mathieu Desnoyers wrote:
> commit 7e5b9a4d1a4a63fac405ed74c42f93abdc223794
> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> Date:   Wed Mar 13 12:23:11 2013 -0400
> 
>     list: implement cds_list_for_each_safe()
>     
>     Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>

Reviewed-by: Paul E. McKenney <paulmck at linux.vnet.ibm.com>

> diff --git a/urcu/list.h b/urcu/list.h
> index 5d04394..1d1c7b5 100644
> --- a/urcu/list.h
> +++ b/urcu/list.h
> @@ -140,12 +140,17 @@ cds_list_splice (struct cds_list_head *add, struct cds_list_head *head)
>  #define cds_list_for_each(pos, head) \
>    for (pos = (head)->next; pos != (head); pos = pos->next)
> 
> +/* Iterate forward over the elements list. The list elements can be
> +   removed from the list while doing this.  */
> +#define cds_list_for_each_safe(pos, p, head) \
> +  for (pos = (head)->next, p = pos->next; \
> +       pos != (head); \
> +       pos = p, p = pos->next)
> 
>  /* Iterate backward over the elements of the list.  */
>  #define cds_list_for_each_prev(pos, head) \
>    for (pos = (head)->prev; pos != (head); pos = pos->prev)
> 
> -
>  /* Iterate backwards over the elements list.  The list elements can be
>     removed from the list while doing this.  */
>  #define cds_list_for_each_prev_safe(pos, p, head) \
> 
> -- 
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
> 




More information about the lttng-dev mailing list