ruby-changes:13992
From: shyouhei <ko1@a...>
Date: Mon, 16 Nov 2009 19:55:27 +0900 (JST)
Subject: [ruby-changes:13992] Ruby:r25800 (ruby_1_8_7): merge revision(s) 23353:
shyouhei 2009-11-16 19:53:12 +0900 (Mon, 16 Nov 2009) New Revision: 25800 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25800 Log: merge revision(s) 23353: * util.c: suppress strict-aliasing warning with gcc-4.4.0 -O2 to fix infinite loop by ruby -e "1.402e-45" . Modified files: branches/ruby_1_8_7/ChangeLog branches/ruby_1_8_7/util.c branches/ruby_1_8_7/version.h Index: ruby_1_8_7/util.c =================================================================== --- ruby_1_8_7/util.c (revision 25799) +++ ruby_1_8_7/util.c (revision 25800) @@ -956,24 +956,26 @@ typedef union { double d; ULong L[2]; } U; #ifdef YES_ALIAS -#define dval(x) x -#ifdef IEEE_LITTLE_ENDIAN -#define word0(x) ((ULong *)&x)[1] -#define word1(x) ((ULong *)&x)[0] +typedef double double_u; +# define dval(x) x +# ifdef IEEE_LITTLE_ENDIAN +# define word0(x) (((ULong *)&x)[1]) +# define word1(x) (((ULong *)&x)[0]) +# else +# define word0(x) (((ULong *)&x)[0]) +# define word1(x) (((ULong *)&x)[1]) +# endif #else -#define word0(x) ((ULong *)&x)[0] -#define word1(x) ((ULong *)&x)[1] +typedef U double_u; +# ifdef IEEE_LITTLE_ENDIAN +# define word0(x) (x.L[1]) +# define word1(x) (x.L[0]) +# else +# define word0(x) (x.L[0]) +# define word1(x) (x.L[1]) +# endif +# define dval(x) (x.d) #endif -#else -#ifdef IEEE_LITTLE_ENDIAN -#define word0(x) ((U*)&x)->L[1] -#define word1(x) ((U*)&x)->L[0] -#else -#define word0(x) ((U*)&x)->L[0] -#define word1(x) ((U*)&x)->L[1] -#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 @@ -1702,10 +1704,11 @@ } static double -ulp(double x) +ulp(double x_) { register Long L; - double a; + double_u x, a; + dval(x) = x_; L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; #ifndef Avoid_Underflow @@ -1743,7 +1746,7 @@ { ULong *xa, *xa0, w, y, z; int k; - double d; + double_u d; #ifdef VAX ULong d0, d1; #else @@ -1804,8 +1807,9 @@ } static Bigint * -d2b(double d, int *e, int *bits) +d2b(double d_, int *e, int *bits) { + double_u d; Bigint *b; int de, k; ULong *x, y, z; @@ -1814,6 +1818,9 @@ #endif #ifdef VAX ULong d0, d1; +#endif + dval(d) = d_; +#ifdef VAX d0 = word0(d) >> 16 | word0(d) << 16; d1 = word1(d) >> 16 | word1(d) << 16; #else @@ -1939,7 +1946,7 @@ static double ratio(Bigint *a, Bigint *b) { - double da, db; + double_u da, db; int k, ka, kb; dval(da) = b2d(a, &ka); @@ -2098,7 +2105,8 @@ int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; const char *s, *s0, *s1; - double aadj, aadj1, adj, rv, rv0; + double aadj, adj; + double_u aadj1, rv, rv0; Long L; ULong y, z; Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; @@ -2797,14 +2805,14 @@ } if ((aadj = ratio(delta, bs)) <= 2.) { if (dsign) - aadj = aadj1 = 1.; + aadj = dval(aadj1) = 1.; else if (word1(rv) || word0(rv) & Bndry_mask) { #ifndef Sudden_Underflow if (word1(rv) == Tiny1 && !word0(rv)) goto undfl; #endif aadj = 1.; - aadj1 = -1.; + dval(aadj1) = -1.; } else { /* special case -- power of FLT_RADIX to be */ @@ -2814,12 +2822,12 @@ aadj = 1./FLT_RADIX; else aadj *= 0.5; - aadj1 = -aadj; + dval(aadj1) = -aadj; } } else { aadj *= 0.5; - aadj1 = dsign ? aadj : -aadj; + dval(aadj1) = dsign ? aadj : -aadj; #ifdef Check_FLT_ROUNDS switch (Rounding) { case 2: /* towards +infinity */ @@ -2831,7 +2839,7 @@ } #else if (Flt_Rounds == 0) - aadj1 += 0.5; + dval(aadj1) += 0.5; #endif /*Check_FLT_ROUNDS*/ } y = word0(rv) & Exp_mask; @@ -2841,7 +2849,7 @@ if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { dval(rv0) = dval(rv); word0(rv) -= P*Exp_msk1; - adj = aadj1 * ulp(dval(rv)); + adj = dval(aadj1) * ulp(dval(rv)); dval(rv) += adj; if ((word0(rv) & Exp_mask) >= Exp_msk1*(DBL_MAX_EXP+Bias-P)) { @@ -2861,11 +2869,11 @@ if ((z = aadj) <= 0) z = 1; aadj = z; - aadj1 = dsign ? aadj : -aadj; + dval(aadj1) = dsign ? aadj : -aadj; } word0(aadj1) += (2*P+1)*Exp_msk1 - y; } - adj = aadj1 * ulp(dval(rv)); + adj = dval(aadj1) * ulp(dval(rv)); dval(rv) += adj; #else #ifdef Sudden_Underflow @@ -3178,7 +3186,7 @@ */ char * -dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) +dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve) { /* Arguments ndigits, decpt, sign are similar to those of ecvt and fcvt; trailing zeros are suppressed from @@ -3223,7 +3231,8 @@ ULong x; #endif Bigint *b, *b1, *delta, *mlo = 0, *mhi = 0, *S; - double d2, ds, eps; + double ds; + double_u d, d2, eps; char *s, *s0; #ifdef Honor_FLT_ROUNDS int rounding; @@ -3232,6 +3241,8 @@ int inexact, oldinexact; #endif + dval(d) = d_; + #ifndef MULTIPLE_THREADS if (dtoa_result) { freedtoa(dtoa_result); Index: ruby_1_8_7/ChangeLog =================================================================== --- ruby_1_8_7/ChangeLog (revision 25799) +++ ruby_1_8_7/ChangeLog (revision 25800) @@ -1,3 +1,8 @@ +Mon Nov 16 19:45:27 2009 Tanaka Akira <akr@f...> + + * util.c: suppress strict-aliasing warning with gcc-4.4.0 -O2 to fix + infinite loop by ruby -e "1.402e-45" . + Mon Nov 16 19:28:23 2009 URABE Shyouhei <shyouhei@r...> * ext/bigdecimal/bigdecimal.c (BigDecimal_to_i): revert a part of Index: ruby_1_8_7/version.h =================================================================== --- ruby_1_8_7/version.h (revision 25799) +++ ruby_1_8_7/version.h (revision 25800) @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2009-11-16" #define RUBY_VERSION_CODE 187 #define RUBY_RELEASE_CODE 20091116 -#define RUBY_PATCHLEVEL 203 +#define RUBY_PATCHLEVEL 204 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/