Fix radeon kms compiled with clang.

Christiano F. Haesbaert haesbaert at
Mon Dec 2 06:38:55 PST 2013

On 2 December 2013 04:02, Michel Dänzer <michel at> wrote:
> I think it would be better to address this in xorg_list_for_each_entry()
> or in clang instead of working around it in users of
> xorg_list_for_each_entry(). Have there been any efforts along those
> lines?

It is not straight forward, the problem is clang has no typeof, which
xorg needs to build __container_of.

Check how the comment even says the C standard states it is undefined
behaviour. typeof is a gcc extension.

#define __container_of(ptr, sample, member) \
    container_of(ptr, typeof(*sample), member)
/* This implementation of __container_of has undefined behavior according
 * to the C standard, but it works in many cases.  If your compiler doesn't
 * support typeof() and fails with this implementation, please try a newer
 * compiler.
#define __container_of(ptr, sample, member)                            \
    (void *)((char *)(ptr)                                             \
            - ((char *)&(sample)->member - (char *)(sample)))

#define xorg_list_for_each_entry(pos, head, member) \
    for (pos = __container_of((head)->next, pos, member); \
&pos->member != (head); \
pos = __container_of(pos->, pos, member))

> Anyway, please make sure patches you submit have a Signed-off-by: tag.


More information about the xorg-driver-ati mailing list