[PATCH 1/2] common: add safe version of foreach-list to Linux
Thomas Monjalon
thomas at monjalon.net
Tue Jul 5 18:16:18 CEST 2022
01/06/2022 12:54, Hamza Khan:
> Linux EAL does not have the LIST_FOREACH_SAFE version of the
> iterator macros. Add it.
>
> Signed-off-by: Hamza Khan <hamza.khan at intel.com>
> ---
> lib/eal/linux/include/rte_os.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/lib/eal/linux/include/rte_os.h b/lib/eal/linux/include/rte_os.h
> index c72bf5b7e6..00d7714181 100644
> --- a/lib/eal/linux/include/rte_os.h
> +++ b/lib/eal/linux/include/rte_os.h
> @@ -26,6 +26,13 @@ extern "C" {
> #define RTE_STAILQ_HEAD(name, type) STAILQ_HEAD(name, type)
> #define RTE_STAILQ_ENTRY(type) STAILQ_ENTRY(type)
>
> +#ifndef LIST_FOREACH_SAFE
> +#define LIST_FOREACH_SAFE(var, head, field, tvar) \
> + for ((var) = LIST_FIRST((head)); \
> + (var) && ((tvar) = LIST_NEXT((var), field), 1); \
> + (var) = (tvar))
> +#endif
I'm not sure we want to add such thing without a RTE_ prefix.
And we should not need LIST_*, we have RTE_TAILQ_*.
More information about the dev
mailing list