1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
$NetBSD: patch-cg,v 1.6 2005/10/12 16:39:25 joerg Exp $
--- extensions/transformiix/source/base/Double.cpp.orig 2004-01-15 21:23:18.000000000 +0000
+++ extensions/transformiix/source/base/Double.cpp
@@ -48,8 +48,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 <ieeefp.h>
#ifdef __alpha__
fp_except_t allmask = FP_X_INV|FP_X_OFL|FP_X_UFL|FP_X_DZ|FP_X_IMP;
@@ -127,9 +159,20 @@ const PRUint32 infMask[2] = {0, TX_DO
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
@@ -157,6 +200,7 @@ MBool Double::isNeg(double aDbl)
{
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
@@ -244,7 +288,7 @@ public:
{
if (mState == eIllegal || mBuffer.IsEmpty() ||
(mBuffer.Length() == 1 && mBuffer[0] == '.')) {
- return Double::NaN;
+ return Double::NaN();
}
return mSign*PR_strtod(mBuffer.get(), 0);
}
|