Tweaked a bit by Darin.
- http://bugzilla.opendarwin.org/show_bug.cgi?id=9678
work around MSVCRT's fmod function returning NaN for fmod(x, infinity) instead of x
* wtf/MathExtras.h: Added include of <float.h>.
(isinf): Fix to return false for NAN.
(wtf_fmod): Added. An inline that works around the bug.
* kjs/nodes.cpp:
* kjs/number_object.cpp:
* kjs/operations.cpp:
* kjs/value.cpp:
Added includes of MathExtras.h to all files using fmod.
* JavaScriptCore.xcodeproj/project.pbxproj: Let Xcode 2.3 have its way with
the project.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15155
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-07-04 Bjoern Graf <bjoern.graf@gmail.com>
+
+ Reviewed by Maciej.
+ Tweaked a bit by Darin.
+
+ - http://bugzilla.opendarwin.org/show_bug.cgi?id=9678
+ work around MSVCRT's fmod function returning NaN for fmod(x, infinity) instead of x
+
+ * wtf/MathExtras.h: Added include of <float.h>.
+ (isinf): Fix to return false for NAN.
+ (wtf_fmod): Added. An inline that works around the bug.
+
+ * kjs/nodes.cpp:
+ * kjs/number_object.cpp:
+ * kjs/operations.cpp:
+ * kjs/value.cpp:
+ Added includes of MathExtras.h to all files using fmod.
+
+ * JavaScriptCore.xcodeproj/project.pbxproj: Let Xcode 2.3 have its way with
+ the project.
+
2006-07-01 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin.
E195679909E7CF1200B89D13 /* UnicodeCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = E195679509E7CF1200B89D13 /* UnicodeCategory.h */; };
/* End PBXBuildFile section */
-/* Begin PBXBuildStyle section */
- 14C137130A560E70006CA9AF /* Development */ = {
- isa = PBXBuildStyle;
- buildSettings = {
- COPY_PHASE_STRIP = NO;
- };
- name = Development;
- };
- 14C137140A560E70006CA9AF /* Deployment */ = {
- isa = PBXBuildStyle;
- buildSettings = {
- COPY_PHASE_STRIP = YES;
- };
- name = Deployment;
- };
-/* End PBXBuildStyle section */
-
/* Begin PBXContainerItemProxy section */
141211350A48796100480255 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */;
- buildSettings = {
- };
- buildStyles = (
- 14C137130A560E70006CA9AF /* Development */,
- 14C137140A560E70006CA9AF /* Deployment */,
- );
hasScannedForEncodings = 1;
mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
#include "reference_list.h"
#include <wtf/HashSet.h>
#include <wtf/HashCountedSet.h>
+#include <wtf/MathExtras.h>
using namespace KJS;
#include "dtoa.h"
#include "error_object.h"
#include "operations.h"
+#include <wtf/MathExtras.h>
#include <wtf/Vector.h>
-#include <math.h>
using namespace KJS;
#include "config.h"
#include "operations.h"
+#include "object.h"
#include <math.h>
#include <stdio.h>
+#include <wtf/MathExtras.h>
#if HAVE(FUNC_ISINF) && HAVE(IEEEFP_H)
#include <ieeefp.h>
#include <float.h>
#endif
-#include "object.h"
-
namespace KJS {
#if !PLATFORM(DARWIN)
-// FIXME: should probably be inlined on other platforms too, and controlled exclusively
-// by HAVE macros
-
-
+
+// FIXME: Should probably be inlined on non-Darwin platforms too, and controlled exclusively
+// by HAVE macros rather than PLATFORM.
+
+// FIXME: Merge with isnan in MathExtras.h and remove this one entirely.
bool isNaN(double d)
{
#if HAVE(FUNC_ISNAN)
#endif
}
+// FIXME: Merge with isinf in MathExtras.h and remove this one entirely.
bool isInf(double d)
{
// FIXME: should be HAVE(_FPCLASS)
#include "config.h"
#include "value.h"
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "operations.h"
#include "error_object.h"
#include "nodes.h"
+#include "operations.h"
+#include <stdio.h>
+#include <string.h>
+#include <wtf/MathExtras.h>
namespace KJS {
#include <xmath.h>
-inline bool isinf(double num) { return !_finite(num); }
+#if HAVE(FLOAT_H)
+#include <float.h>
+#endif
+
+inline bool isinf(double num) { return !_finite(num) && !_isnan(num); }
inline bool isnan(double num) { return _isnan(num); }
inline long lround(double num) { return num > 0 ? num + 0.5 : ceil(num - 0.5); }
inline long lroundf(float num) { return num > 0 ? num + 0.5f : ceilf(num - 0.5f); }
inline float roundf(float num) { return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f); }
inline bool signbit(double num) { return _copysign(1.0, num) < 0; }
+#if PLATFORM(WIN) && COMPILER(MSVC)
+
+// Work around a bug in the Microsoft CRT, where fmod(x, +-infinity) yields NaN instead of x.
+inline double wtf_fmod(double x, double y) { return (!isinf(x) && isinf(y)) ? x : fmod(x, y); }
+
+#define fmod(x, y) wtf_fmod(x, y)
+
#endif