Changeset 117779 in webkit


Ignore:
Timestamp:
May 21, 2012 7:24:22 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Colliding isinf/isnan between C99 and C++11 with GCC >=4.6
https://bugs.webkit.org/show_bug.cgi?id=59249

Patch by Allan Sandfeld Jensen <allan.jensen@nokia.com> on 2012-05-21
Reviewed by Darin Adler.

Workaround the isinf and isnan conflict in GCC C++11.

  • wtf/Compiler.h:
  • wtf/MathExtras.h:

(std::wtf_isinf):
(std::wtf_isnan):

Location:
trunk/Source/WTF
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r117744 r117779  
     12012-05-21  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
     2
     3        Colliding isinf/isnan between C99 and C++11 with GCC >=4.6
     4        https://bugs.webkit.org/show_bug.cgi?id=59249
     5
     6        Reviewed by Darin Adler.
     7
     8        Workaround the isinf and isnan conflict in GCC C++11.
     9
     10        * wtf/Compiler.h:
     11        * wtf/MathExtras.h:
     12        (std::wtf_isinf):
     13        (std::wtf_isnan):
     14
    1152012-05-21  Andreas Kling  <kling@webkit.org>
    216
  • trunk/Source/WTF/wtf/Compiler.h

    r116951 r117779  
    3333#define COMPILER_SUPPORTS(WTF_COMPILER_FEATURE) (defined WTF_COMPILER_SUPPORTS_##WTF_COMPILER_FEATURE  && WTF_COMPILER_SUPPORTS_##WTF_COMPILER_FEATURE)
    3434
     35/* COMPILER_QUIRK() - whether the compiler being used to build the project requires a given quirk. */
     36#define COMPILER_QUIRK(WTF_COMPILER_QUIRK) (defined WTF_COMPILER_QUIRK_##WTF_COMPILER_QUIRK  && WTF_COMPILER_QUIRK_##WTF_COMPILER_QUIRK)
     37
    3538/* ==== COMPILER() - the compiler being used to build the project ==== */
    3639
     
    9699#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
    97100#define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000 + minor * 100 + patch))
    98 
    99 /* Specific compiler features */
    100 #if !COMPILER(CLANG) && GCC_VERSION_AT_LEAST(4, 6, 0) && defined(__GXX_EXPERIMENTAL_CXX0X__)
    101 #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
    102 #endif
    103 
    104101#else
    105102/* Define this for !GCC compilers, just so we can write things like GCC_VERSION_AT_LEAST(4, 1, 0). */
    106103#define GCC_VERSION_AT_LEAST(major, minor, patch) 0
     104#endif
     105
     106/* Specific compiler features */
     107#if COMPILER(GCC) && !COMPILER(CLANG)
     108#if GCC_VERSION_AT_LEAST(4, 7, 0) && __cplusplus >= 201103L
     109#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
     110#define WTF_COMPILER_QUIRK_GCC11_GLOBAL_ISINF_ISNAN 1
     111
     112#elif GCC_VERSION_AT_LEAST(4, 6, 0) && defined(__GXX_EXPERIMENTAL_CXX0X__)
     113#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
     114#define WTF_COMPILER_QUIRK_GCC11_GLOBAL_ISINF_ISNAN 1
     115#endif
     116
    107117#endif
    108118
  • trunk/Source/WTF/wtf/MathExtras.h

    r111778 r117779  
    280280#if !COMPILER(MSVC) && !COMPILER(RVCT) && !OS(SOLARIS)
    281281using std::isfinite;
     282#if !COMPILER_QUIRK(GCC11_GLOBAL_ISINF_ISNAN)
    282283using std::isinf;
    283284using std::isnan;
     285#endif
    284286using std::signbit;
    285287#endif
     288
     289#if COMPILER_QUIRK(GCC11_GLOBAL_ISINF_ISNAN)
     290// A workaround to avoid conflicting declarations of isinf and isnan when compiling with GCC in C++11 mode.
     291namespace std {
     292    constexpr bool wtf_isinf(float f) { return std::isinf(f); }
     293    constexpr bool wtf_isinf(double d) { return std::isinf(d); }
     294    constexpr bool wtf_isnan(float f) { return std::isnan(f); }
     295    constexpr bool wtf_isnan(double d) { return std::isnan(d); }
     296};
     297
     298using std::wtf_isinf;
     299using std::wtf_isnan;
     300
     301#define isinf(x) wtf_isinf(x)
     302#define isnan(x) wtf_isnan(x)
     303#endif
     304
    286305
    287306// decompose 'number' to its sign, exponent, and mantissa components.
Note: See TracChangeset for help on using the changeset viewer.