r300g: Avoid aliasing violation.
authorMatt Turner <mattst88@gmail.com>
Thu, 28 Jul 2016 20:57:06 +0000 (13:57 -0700)
committerMatt Turner <mattst88@gmail.com>
Mon, 1 Aug 2016 19:09:17 +0000 (12:09 -0700)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/r300/compiler/radeon_inline_literals.c

index 492f00eea5f0eb3a254b3c6f79f505037cb11bcd..c40a3807de48a126cd2d7ff25f5bc60d42fee2d7 100644 (file)
@@ -28,6 +28,7 @@
 #include "radeon_dataflow.h"
 #include "radeon_program.h"
 #include "radeon_program_constants.h"
+#include "util/u_bitcast.h"
 #include <stdio.h>
 
 #define VERBOSE 0
@@ -45,7 +46,7 @@
  */
 static int ieee_754_to_r300_float(float f, unsigned char *r300_float_out)
 {
-       unsigned float_bits = *((unsigned *)&f);
+       unsigned float_bits = u_bitcast_f2u(f);
        /* XXX: Handle big-endian */
        unsigned mantissa = float_bits &         0x007fffff;
        unsigned biased_exponent = (float_bits & 0x7f800000) >> 23;