[PATCH 14/16] Define __container_of only if not defined yet.
Ville Syrjälä
ville.syrjala at linux.intel.com
Fri Mar 21 22:19:35 UTC 2025
On Tue, Mar 04, 2025 at 04:58:07PM +0100, Enrico Weigelt, metux IT consult wrote:
> Silence warnings.
>
> Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
> ---
> benchmarks/dri3-swap.c | 2 ++
> src/intel_list.h | 3 +++
> test/present-speed.c | 2 ++
Looks like I never added the benchmarks and tests to the meson
build. So that could partially explain why I'm not seeing this.
But intel_list.h is used for real so I'm confused as to why
you are seeing some issues that I can't see.
Who is defining this in your case?
> 3 files changed, 7 insertions(+)
>
> diff --git a/benchmarks/dri3-swap.c b/benchmarks/dri3-swap.c
> index 4dd423b3..fa8ec34e 100644
> --- a/benchmarks/dri3-swap.c
> +++ b/benchmarks/dri3-swap.c
> @@ -110,8 +110,10 @@ list_move(struct list *list, struct list *head)
> }
> }
>
> +#ifndef __container_of
> #define __container_of(ptr, sample, member) \
> (void *)((char *)(ptr) - ((char *)&(sample)->member - (char *)(sample)))
> +#endif
>
> #define list_for_each_entry(pos, head, member) \
> for (pos = __container_of((head)->next, pos, member); \
> diff --git a/src/intel_list.h b/src/intel_list.h
> index c8a3187a..f0fe7af9 100644
> --- a/src/intel_list.h
> +++ b/src/intel_list.h
> @@ -305,8 +305,11 @@ list_is_empty(const struct list *head)
> #define list_last_entry(ptr, type, member) \
> list_entry((ptr)->prev, type, member)
>
> +#ifndef __container_of
> #define __container_of(ptr, sample, member) \
> (void *)((char *)(ptr) - ((char *)&(sample)->member - (char *)(sample)))
> +#endif
> +
> /**
> * Loop through the list given by head and set pos to struct in the list.
> *
> diff --git a/test/present-speed.c b/test/present-speed.c
> index eccde931..7765aa94 100644
> --- a/test/present-speed.c
> +++ b/test/present-speed.c
> @@ -108,8 +108,10 @@ list_move(struct list *list, struct list *head)
> }
> }
>
> +#ifndef __container_of
> #define __container_of(ptr, sample, member) \
> (void *)((char *)(ptr) - ((char *)&(sample)->member - (char *)(sample)))
> +#endif
>
> #define list_for_each_entry(pos, head, member) \
> for (pos = __container_of((head)->next, pos, member); \
> --
> 2.39.5
--
Ville Syrjälä
Intel
More information about the Intel-gfx
mailing list