[PATCH wayland] server: use void* instead of function pointer for wl_object.implementation

Thiago Macieira thiago.macieira at intel.com
Thu Mar 28 08:08:52 PDT 2013


On quinta-feira, 28 de março de 2013 14.55.51, Giulio Camuffo wrote:
> use a union { void *obj; void (* const *func)(); }; in wl_resource_init()
> in wayland-server.h to convert between the two (really ugly imho) or 
> uninline wl_resource_init() and put the implementation somewhere the c++
> compiler doesn't see.

FYI but it probably does NOT affect Wayland:

The union conversion trick is undefined behaviour in C++98 and C99. Both 
standards say that it is undefined to read from an union member that was not 
the last one stored. This is especially important if you use the store-A 
modify-B read-A pattern, as the compiler might optimise the modification out of 
existence.

GCC hardcodes the behaviour that reading from a member that was not the last 
stored means reinterpreting the bits of the union. I believe other GCC-
compatible compilers (Clang and Intel Compiler) do the same. This behaviour 
was also specified for C++11. I haven't checked if C11 also has it.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130328/b987fc17/attachment.pgp>


More information about the wayland-devel mailing list