Changeset 138894 in webkit


Ignore:
Timestamp:
Jan 5, 2013 12:02:49 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Fix compilation of MathExtras.h with MinGW-w64
https://bugs.webkit.org/show_bug.cgi?id=106105

Patch by Jonathan Liu <net147@gmail.com> on 2013-01-05
Reviewed by Simon Hausmann.

The isfinite and isinf functions are required by wtf_pow but
not defined until after wtf_pow. Move wtf_pow to after
"using std::isfinite" and "using std::isinf" to fix compilation.

  • wtf/MathExtras.h:

(wtf_pow):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r138737 r138894  
     12013-01-05  Jonathan Liu  <net147@gmail.com>
     2
     3        Fix compilation of MathExtras.h with MinGW-w64
     4        https://bugs.webkit.org/show_bug.cgi?id=106105
     5
     6        Reviewed by Simon Hausmann.
     7
     8        The isfinite and isinf functions are required by wtf_pow but
     9        not defined until after wtf_pow. Move wtf_pow to after
     10        "using std::isfinite" and "using std::isinf" to fix compilation.
     11
     12        * wtf/MathExtras.h:
     13        (wtf_pow):
     14
    1152013-01-03  Filip Pizlo  <fpizlo@apple.com>
    216
  • trunk/Source/WTF/wtf/MathExtras.h

    r138705 r138894  
    227227#endif // COMPILER(MSVC)
    228228
    229 #if COMPILER(MINGW64)
    230 inline double wtf_pow(double x, double y)
    231 {
    232     // MinGW-w64 has a custom implementation for pow.
    233     // This handles certain special cases that are different.
    234     if ((x == 0.0 || isinf(x)) && isfinite(y)) {
    235         double f;
    236         if (modf(y, &f) != 0.0)
    237             return ((x == 0.0) ^ (y > 0.0)) ? std::numeric_limits<double>::infinity() : 0.0;
    238     }
    239 
    240     if (x == 2.0) {
    241         int yInt = static_cast<int>(y);
    242         if (y == yInt)
    243             return ldexp(1.0, yInt);
    244     }
    245 
    246     return pow(x, y);
    247 }
    248 #define pow(x, y) wtf_pow(x, y)
    249 #endif // COMPILER(MINGW64)
    250 
    251229inline double deg2rad(double d)  { return d * piDouble / 180.0; }
    252230inline double rad2deg(double r)  { return r * 180.0 / piDouble; }
     
    369347#endif
    370348#endif
     349
     350#if COMPILER(MINGW64)
     351inline double wtf_pow(double x, double y)
     352{
     353    // MinGW-w64 has a custom implementation for pow.
     354    // This handles certain special cases that are different.
     355    if ((x == 0.0 || isinf(x)) && isfinite(y)) {
     356        double f;
     357        if (modf(y, &f) != 0.0)
     358            return ((x == 0.0) ^ (y > 0.0)) ? std::numeric_limits<double>::infinity() : 0.0;
     359    }
     360
     361    if (x == 2.0) {
     362        int yInt = static_cast<int>(y);
     363        if (y == yInt)
     364            return ldexp(1.0, yInt);
     365    }
     366
     367    return pow(x, y);
     368}
     369#define pow(x, y) wtf_pow(x, y)
     370#endif // COMPILER(MINGW64)
    371371
    372372
Note: See TracChangeset for help on using the changeset viewer.