skia: Fix aliasing violations

With the worst violations moved to skia/legacy, this has become
fixable -- fix the remaining aliasing violations and get rid of
-fno-strict-aliasing

Change-Id: I5b30058c01711f6eb4fb2f63a77f89ff183433b8
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
diff --git a/Android.mk b/Android.mk
index c3c4dc5..644b173 100644
--- a/Android.mk
+++ b/Android.mk
@@ -504,11 +504,6 @@
 	$(LOCAL_PATH)/include/ports \
 	$(LOCAL_PATH)/include/utils
 
-# FIXME this should really be limited to files that need it, such as
-# src/utils/SkCamera.cpp -- pretty bad violations going on in there,
-# but most of the rest of skia is good
-LOCAL_CFLAGS += -fno-strict-aliasing
-
 LOCAL_LDLIBS += -lpthread
 
 LOCAL_MODULE:= libskia
diff --git a/include/core/SkFloatingPoint.h b/include/core/SkFloatingPoint.h
index 96270b0..0bbd434 100644
--- a/include/core/SkFloatingPoint.h
+++ b/include/core/SkFloatingPoint.h
@@ -91,7 +91,16 @@
 extern const uint32_t gIEEEInfinity;
 extern const uint32_t gIEEENegativeInfinity;
 
+#if 0
 #define SK_FloatNaN                 (*reinterpret_cast<const float*>(&gIEEENotANumber))
 #define SK_FloatInfinity            (*reinterpret_cast<const float*>(&gIEEEInfinity))
 #define SK_FloatNegativeInfinity    (*reinterpret_cast<const float*>(&gIEEENegativeInfinity))
+#else
+// Note: NAN is a 0x7fc00000 NaN while gIEEENotANumber is 0x7fffffff, so
+// using this definition may break some bogus code (using x == SK_FloatNaN
+// rather than isnan() or the likes to check for NaN)
+#define SK_FloatNaN                 NAN
+#define SK_FloatInfinity            INFINITY
+#define SK_FloatNegativeInfinity    -INFINITY
+#endif
 #endif
diff --git a/include/utils/SkRandom.h b/include/utils/SkRandom.h
index 150384d..9652237 100644
--- a/include/utils/SkRandom.h
+++ b/include/utils/SkRandom.h
@@ -196,9 +196,12 @@
      *  Returns value [0...1) as an IEEE float
      */
     float nextF() {
-        unsigned int floatint = 0x3f800000 | (this->nextU() >> 9);
-        float f = *(float*)(&floatint) - 1.0f;
-        return f;
+        union {
+            unsigned int i;
+            float f;
+        } flt;
+        flt.i = 0x3f800000 | (this->nextU() >> 9);
+        return flt.f - 1.0f;
     }
 
     /**