i965: Use a union to bitcast a float
authorMatt Turner <mattst88@gmail.com>
Thu, 19 Oct 2017 05:16:05 +0000 (22:16 -0700)
committerMatt Turner <mattst88@gmail.com>
Thu, 19 Oct 2017 05:16:46 +0000 (22:16 -0700)
... which does not break C's aliasing rules.

src/mesa/drivers/dri/i965/gen6_constant_state.c

index 62ad6b04976fbda57ff094726ba437fa45f7a386..121ba6725754a0708b640e95373e5e3a93f594f1 100644 (file)
@@ -32,7 +32,8 @@
 static uint32_t
 f_as_u32(float f)
 {
-   return *(uint32_t *)&f;
+   union fi fi = { .f = f };
+   return fi.ui;
 }
 
 static uint32_t