fixes bug 209814 "PR_dtoa blows up when executed on an ARM platform" patch by wtc r=darin a=brendan NSPRPUB_PRE_4_2_CLIENT_BRANCH MOZILLA_1_7b_RELEASE
authordarin%meer.net
Fri, 12 Mar 2004 07:30:50 +0000
branchNSPRPUB_PRE_4_2_CLIENT_BRANCH
changeset 3052 61fc3075278f3cdd833de98369df28906a184436
parent 3050 b97f85087b24ea3897815ec5d635092bbfd97cbf
child 3056 dee2dd6d4ca530809300944876d101b24e33b19e
push idunknown
push userunknown
push dateunknown
reviewersdarin, brendan
bugs209814
fixes bug 209814 "PR_dtoa blows up when executed on an ARM platform" patch by wtc r=darin a=brendan
pr/src/misc/prdtoa.c
--- a/pr/src/misc/prdtoa.c
+++ b/pr/src/misc/prdtoa.c
@@ -92,16 +92,19 @@
  *		for 0 <= k <= 22).
  */
 
 /*
  * #define IEEE_8087 for IEEE-arithmetic machines where the least
  *	significant byte has the lowest address.
  * #define IEEE_MC68k for IEEE-arithmetic machines where the most
  *	significant byte has the lowest address.
+ * #define IEEE_ARM for IEEE-arithmetic machines where the two words
+ *	in a double are stored in big endian order but the two shorts
+ * 	in a word are still stored in little endian order.
  * #define Long int on machines with 32-bit ints and 64-bit longs.
  * #define Sudden_Underflow for IEEE-format machines without gradual
  *	underflow (i.e., that flush to zero on underflow).
  * #define IBM for IBM mainframe-style floating-point arithmetic.
  * #define VAX for VAX-style floating-point arithmetic.
  * #define Unsigned_Shifts if >> does treats its left operand as unsigned.
  * #define No_leftright to omit left-right logic in fast floating-point
  *	computation of PR_dtoa.
@@ -124,17 +127,20 @@
  *	appropriate.  If MALLOC is undefined, malloc will be invoked
  *	directly -- and assumed always to succeed.
  * #define YES_ALIAS to permit aliasing certain double values with
  *	arrays of unsigned Longs.  This leads to slightly better code with
  *	some compilers and was always used prior to 19990916, but it
  *	is not strictly legal and can cause trouble with aggressively
  *	optimizing compilers (e.g., gcc 2.95.1 under -O2).
  */
-#if  defined(IS_LITTLE_ENDIAN)
+#if defined(__arm) || defined(__arm__) || defined(__arm26__) \
+    || defined(__arm32__)
+#define IEEE_ARM
+#elif defined(IS_LITTLE_ENDIAN)
 #define IEEE_8087
 #else
 #define IEEE_MC68k
 #endif
 
 #ifndef Long
 #if PR_BYTES_PER_LONG == 4
 #define Long long
@@ -164,16 +170,19 @@ extern void *MALLOC(size_t);
 #ifdef Bad_float_h
 #undef __STDC__
 #ifdef IEEE_MC68k
 #define IEEE_ARITHMETIC
 #endif
 #ifdef IEEE_8087
 #define IEEE_ARITHMETIC
 #endif
+#ifdef IEEE_ARM
+#define IEEE_ARITHMETIC
+#endif
 
 #ifdef IEEE_ARITHMETIC
 #define DBL_DIG 15
 #define DBL_MAX_10_EXP 308
 #define DBL_MAX_EXP 1024
 #define FLT_RADIX 2
 #define FLT_ROUNDS 1
 #define DBL_MAX 1.7976931348623157e+308
@@ -222,18 +231,18 @@ extern void *MALLOC(size_t);
 #endif
 
 #ifdef Unsigned_Shifts
 #define Sign_Extend(a,b) if (b < 0) a |= 0xffff0000;
 #else
 #define Sign_Extend(a,b) /*no-op*/
 #endif
 
-#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM)	!= 1
-Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
+#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(IEEE_ARM) + defined(VAX) + defined(IBM)	!= 1
+Exactly one of IEEE_8087, IEEE_MC68k, IEEE_ARM, VAX, or IBM should be defined.
 #endif
 
 typedef union { double d; unsigned Long L[2]; } U;
 
 #ifdef YES_ALIAS
 #define dval(x) x
 #ifdef IEEE_8087
 #define word0(x) ((unsigned Long *)&x)[1]
@@ -252,31 +261,31 @@ typedef union { double d; unsigned Long 
 #endif
 #define dval(x) ((U*)&x)->d
 #endif
 
 /* The following definition of Storeinc is appropriate for MIPS processors.
  * An alternative that might be better on some machines is
  * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
  */
-#if defined(IEEE_8087) + defined(VAX)
+#if defined(IEEE_8087) + defined(IEEE_ARM) + defined(VAX)
 #define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
 ((unsigned short *)a)[0] = (unsigned short)c, a++)
 #else
 #define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
 ((unsigned short *)a)[1] = (unsigned short)c, a++)
 #endif
 
 /* #define P DBL_MANT_DIG */
 /* Ten_pmax = floor(P*log(2)/log(5)) */
 /* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
 /* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
 /* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
 
-#if defined(IEEE_8087) + defined(IEEE_MC68k)
+#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(IEEE_ARM)
 #define Exp_shift  20
 #define Exp_shift1 20
 #define Exp_msk1    0x100000
 #define Exp_msk11   0x100000
 #define Exp_mask  0x7ff00000
 #define P 53
 #define Bias 1023
 #define IEEE_Arith