Changeset 17091 in webkit for trunk/JavaScriptCore/wtf


Ignore:
Timestamp:
Oct 17, 2006, 2:46:36 PM (19 years ago)
Author:
kmccullo
Message:

Reviewed by Brady.

Fixes a JavaScriptCore math issue on win.

  • kjs/math_object.cpp: (MathFuncImp::callAsFunction):
  • wtf/MathExtras.h: (wtf_atan2):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/MathExtras.h

    r16487 r17091  
    2424 */
    2525
     26#ifndef MATH_EXTRAS_H_
     27#define MATH_EXTRAS_H_
     28
    2629#include <math.h>
    2730
    2831#if PLATFORM(WIN)
    2932
     33#include "kjs/operations.h"
     34#include "kjs/value.h"
    3035#include <xmath.h>
     36#include <limits>
    3137
    3238#if HAVE(FLOAT_H)
     
    4854inline int isfinite(double x) { return _finite(x); }
    4955
     56#ifndef M_PI
     57#define M_PI 3.14159265358979323846
     58#endif  //  M_PI
     59
     60#ifndef M_PI_4
     61#define M_PI_4 0.785398163397448309616
     62#endif  //  M_PI_4
     63
     64// Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN instead of specific values.
     65inline double wtf_atan2(double x, double y)
     66{
     67    static double posInf = std::numeric_limits<double>::infinity();
     68    static double negInf = -std::numeric_limits<double>::infinity();
     69
     70    double result = KJS::NaN;
     71
     72    if (x == posInf && y == posInf)
     73        result = M_PI_4;
     74    else if (x == posInf && y == negInf)
     75        result = 3 * M_PI_4;
     76    else if (x == negInf && y == posInf)
     77        result = -M_PI_4;
     78    else if (x == negInf && y == negInf)
     79        result = -3 * M_PI_4;
     80    else
     81        result = ::atan2(x, y);
     82
     83    return result;
     84}
     85
    5086#if COMPILER(MSVC)
    5187
     
    5591#define fmod(x, y) wtf_fmod(x, y)
    5692
    57 #endif
     93#endif // #if COMPILER(MSVC)
    5894
    59 #endif
     95#define atan2(x, y) wtf_atan2(x, y)
     96
     97#endif // #if PLATFORM(WIN)
     98
     99#endif // #ifndef MATH_EXTRAS_H_
Note: See TracChangeset for help on using the changeset viewer.