$NetBSD: patch-cg,v 1.8 2007/05/12 13:53:09 ghen Exp $ diff -ruN ../Orig/mozilla/extensions/transformiix/source/base/Double.cpp ./extensions/transformiix/source/base/Double.cpp --- ../Orig/mozilla/extensions/transformiix/source/base/Double.cpp 2004-06-17 09:12:42.000000000 +0900 +++ ./extensions/transformiix/source/base/Double.cpp 2005-12-04 19:39:05.000000000 +0900 @@ -49,8 +49,40 @@ * Utility class for doubles */ +#if defined(INFINITY) && defined(NAN) +double Double::NaN() +{ + return NAN; +} + +double Double::PositiveInfinity() +{ + return INFINITY; +} + +double Double::NegativeInfinity() +{ + return -INFINITY; +} + +MBool Double::isInfinite(double aDbl) +{ + return isinf(aDbl); +} + +MBool Double::isNaN(double aDbl) +{ + return isnan(aDbl); +} + +MBool Double::isNeg(double aDbl) +{ + return aDbl<0.0; +} +#else /* pre INFINITY C environment */ + //A trick to handle IEEE floating point exceptions on FreeBSD - E.D. -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__DragonFly__) #include #ifdef __alpha__ fp_except_t allmask = FP_X_INV|FP_X_OFL|FP_X_UFL|FP_X_DZ|FP_X_IMP; @@ -128,9 +160,20 @@ const PRUint32 negInfMask[2] = {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); +double Double::NaN() +{ + return *((double*)nanMask); +} + +double Double::PositiveInfinity() +{ + return *((double*)infMask); +} + +double Double::NegativeInfinity() +{ + return *((double*)negInfMask); +} /* * Determines whether the given double represents positive or negative @@ -158,6 +201,7 @@ { return (TX_DOUBLE_HI32(aDbl) & TX_DOUBLE_HI32_SIGNBIT) != 0; } +#endif /* C environment has INFINITY and NAN */ /* * Converts the given String to a double, if the String value does not @@ -245,7 +289,7 @@ { if (mState == eIllegal || mBuffer.IsEmpty() || (mBuffer.Length() == 1 && mBuffer[0] == '.')) { - return Double::NaN; + return Double::NaN(); } return mSign*PR_strtod(mBuffer.get(), 0); }