virgl: Fix a strict-aliasing violation in the encoder
authorEdward O'Callaghan <funfunctor@folklore1984.net>
Mon, 5 Dec 2016 23:43:17 +0000 (10:43 +1100)
committerEdward O'Callaghan <funfunctor@folklore1984.net>
Mon, 12 Dec 2016 05:50:15 +0000 (16:50 +1100)
commit5e6b2b05a5d6c09f103db59e7dcda10ccfeceae5
tree87f5af2f977dc2ce128c9e6d10a10941e90a1bf5
parent35c5a9a64df013a385b7bb5291c24a2f300ef57b
virgl: Fix a strict-aliasing violation in the encoder

As per the C spec, it is illegal to alias pointers to different
types. This results in undefined behaviour after optimization
passes, resulting in very subtle bugs that happen only on a
full moon..

Use a memcpy() as a well defined coercion between the double
to uint64_t interpretations of the memory.

V.2: Use static_assert() instead of assert().
V.3: Use C99 compat STATIC_ASSERT() over C11 static_assert().

Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Acked-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/virgl/virgl_encode.c