[PATCH libinput 1/5] util: drop GCC specifics for container_of
Armin Krezović
krezovic.armin at gmail.com
Wed May 10 10:26:46 UTC 2017
On 10.05.2017 05:47, Peter Hutterer wrote:
> clang supports __typeof__ which was the only real difference. Not sure any
> other compilers matter (that don't support __typeof__)
>
Hi,
Fun fact: Clang defines __GNUC__ because it's gcc compatible
and the gcc path was always used by clang, the other one
was not used by anything.
Nevertheless, for the series
Reviewed-by: Armin Krezović <krezovic.armin at gmail.com>
Tested-by: Armin Krezović <krezovic.armin at gmail.com>
Please backport these to 1.7 branch (or at least the one that
fixes container_of).
Thanks, Armin.
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> src/libinput-util.h | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/src/libinput-util.h b/src/libinput-util.h
> index 4e97e011..a9a2b660 100644
> --- a/src/libinput-util.h
> +++ b/src/libinput-util.h
> @@ -85,15 +85,9 @@ void list_insert(struct list *list, struct list *elm);
> void list_remove(struct list *elm);
> bool list_empty(const struct list *list);
>
> -#ifdef __GNUC__
> #define container_of(ptr, sample, member) \
> (__typeof__(sample))((char *)(ptr) - \
> ((char *)&(sample)->member - (char *)(sample)))
> -#else
> -#define container_of(ptr, sample, member) \
> - (void *)((char *)(ptr) - \
> - ((char *)&(sample)->member - (char *)(sample)))
> -#endif
>
> #define list_for_each(pos, head, member) \
> for (pos = 0, pos = container_of((head)->next, pos, member); \
>
More information about the wayland-devel
mailing list