Bug 289394 - "Double.cpp causes unaligned accesses" [p=davidm@hpl.hp.com (David Mosberger) / eric@debian.org (Eric Dorland) / mh+mozilla@glandium.org (Mike Hommey) r+sr=sicking sr=bryner a1.9=beltzner]
authorreed@reedloden.com
Fri, 25 Jan 2008 00:02:04 -0800
changeset 10650 fdac62e64242104faf42cfa1ade13a35044d268d
parent 10649 6c5a736dd0cd152634579cc22bfcf57f061d1840
child 10651 bf0b963d5f684669a724bd66273023fa667cff73
push idunknown
push userunknown
push dateunknown
reviewersbryner
bugs289394
milestone1.9b3pre
Bug 289394 - "Double.cpp causes unaligned accesses" [p=davidm@hpl.hp.com (David Mosberger) / eric@debian.org (Eric Dorland) / mh+mozilla@glandium.org (Mike Hommey) r+sr=sicking sr=bryner a1.9=beltzner]
content/xslt/public/txDouble.h
content/xslt/src/base/txDouble.cpp
--- a/content/xslt/public/txDouble.h
+++ b/content/xslt/public/txDouble.h
@@ -63,33 +63,32 @@ static fp_except_t oldmask = fpsetmask(~
  */
 
 #if defined(__arm) || defined(__arm32__) || defined(__arm26__) || defined(__arm__)
 #if !defined(__VFP_FP__)
 #define FPU_IS_ARM_FPA
 #endif
 #endif
 
-#if (__GNUC__ == 2 && __GNUC_MINOR__ > 95) || __GNUC__ > 2
-/**
- * This version of the macros is safe for the alias optimizations
- * that gcc does, but uses gcc-specific extensions.
- */
-
 typedef union txdpun {
-    PRFloat64 d;
     struct {
 #if defined(IS_LITTLE_ENDIAN) && !defined(FPU_IS_ARM_FPA)
         PRUint32 lo, hi;
 #else
         PRUint32 hi, lo;
 #endif
     } s;
+    PRFloat64 d;
 } txdpun;
 
+#if (__GNUC__ == 2 && __GNUC_MINOR__ > 95) || __GNUC__ > 2
+/**
+ * This version of the macros is safe for the alias optimizations
+ * that gcc does, but uses gcc-specific extensions.
+ */
 #define TX_DOUBLE_HI32(x) (__extension__ ({ txdpun u; u.d = (x); u.s.hi; }))
 #define TX_DOUBLE_LO32(x) (__extension__ ({ txdpun u; u.d = (x); u.s.lo; }))
 
 #else // __GNUC__
 
 /* We don't know of any non-gcc compilers that perform alias optimization,
  * so this code should work.
  */
@@ -108,21 +107,21 @@ typedef union txdpun {
 #define TX_DOUBLE_HI32_EXPMASK   0x7ff00000
 #define TX_DOUBLE_HI32_MANTMASK  0x000fffff
 
 #define TX_DOUBLE_IS_NaN(x)                                                \
 ((TX_DOUBLE_HI32(x) & TX_DOUBLE_HI32_EXPMASK) == TX_DOUBLE_HI32_EXPMASK && \
  (TX_DOUBLE_LO32(x) || (TX_DOUBLE_HI32(x) & TX_DOUBLE_HI32_MANTMASK)))
 
 #ifdef IS_BIG_ENDIAN
-#define TX_DOUBLE_NaN {TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK,   \
-                       0xffffffff}
+#define TX_DOUBLE_NaN {{TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK,   \
+                        0xffffffff}}
 #else
-#define TX_DOUBLE_NaN {0xffffffff,                                         \
-                       TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK}
+#define TX_DOUBLE_NaN {{0xffffffff,                                         \
+                        TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK}}
 #endif
 
 #if defined(XP_WIN)
 #define TX_DOUBLE_COMPARE(LVAL, OP, RVAL)                                  \
     (!TX_DOUBLE_IS_NaN(LVAL) && !TX_DOUBLE_IS_NaN(RVAL) && (LVAL) OP (RVAL))
 #else
 #define TX_DOUBLE_COMPARE(LVAL, OP, RVAL) ((LVAL) OP (RVAL))
 #endif
--- a/content/xslt/src/base/txDouble.cpp
+++ b/content/xslt/src/base/txDouble.cpp
@@ -45,28 +45,28 @@
 #endif
 #include "prdtoa.h"
 
 /*
  * Utility class for doubles
  */
 
 //-- Initialize Double related constants
-const PRUint32 nanMask[2] =    TX_DOUBLE_NaN;
+const txdpun nanMask =    TX_DOUBLE_NaN;
 #ifdef IS_BIG_ENDIAN
-const PRUint32 infMask[2] =    {TX_DOUBLE_HI32_EXPMASK, 0};
-const PRUint32 negInfMask[2] = {TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT, 0};
+const txdpun infMask =    {{TX_DOUBLE_HI32_EXPMASK, 0}};
+const txdpun negInfMask = {{TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT, 0}};
 #else
-const PRUint32 infMask[2] =    {0, TX_DOUBLE_HI32_EXPMASK};
-const PRUint32 negInfMask[2] = {0, TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT};
+const txdpun infMask =    {{0, TX_DOUBLE_HI32_EXPMASK}};
+const txdpun negInfMask = {{0, TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT}};
 #endif
 
-const double Double::NaN = *((double*)nanMask);
-const double Double::POSITIVE_INFINITY = *((double*)infMask);
-const double Double::NEGATIVE_INFINITY = *((double*)negInfMask);
+const double Double::NaN = nanMask.d;
+const double Double::POSITIVE_INFINITY = infMask.d;
+const double Double::NEGATIVE_INFINITY = negInfMask.d;
 
 /*
  * Determines whether the given double represents positive or negative
  * inifinity
  */
 MBool Double::isInfinite(double aDbl)
 {
     return ((TX_DOUBLE_HI32(aDbl) & ~TX_DOUBLE_HI32_SIGNBIT) == TX_DOUBLE_HI32_EXPMASK &&