diff options
Diffstat (limited to 'src/3rdparty/javascriptcore/JavaScriptCore/wtf')
5 files changed, 48 insertions, 29 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/DateMath.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/DateMath.cpp index e72f94b..a6eb0d6 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/DateMath.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/DateMath.cpp @@ -846,7 +846,7 @@ double parseDateFromNullTerminatedCharacters(const char* dateString) bool haveTZ; int offset; double ms = parseDateFromNullTerminatedCharacters(dateString, haveTZ, offset); - if (isnan(ms)) + if (std::isnan(ms)) return NaN; // fall back to local timezone @@ -858,7 +858,7 @@ double parseDateFromNullTerminatedCharacters(const char* dateString) double timeClip(double t) { - if (!isfinite(t)) + if (!std::isfinite(t)) return NaN; if (fabs(t) > maxECMAScriptTime) return NaN; @@ -971,7 +971,7 @@ double parseDateFromNullTerminatedCharacters(ExecState* exec, const char* dateSt bool haveTZ; int offset; double ms = WTF::parseDateFromNullTerminatedCharacters(dateString, haveTZ, offset); - if (isnan(ms)) + if (std::isnan(ms)) return NaN; // fall back to local timezone diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashTable.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashTable.h index 42a9233..8149375 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashTable.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashTable.h @@ -257,19 +257,20 @@ namespace WTF { using std::swap; -#if !COMPILER(MSVC) && !OS(QNX) && !defined(_LIBCPP_VERSION) - // The Dinkumware C++ library (used by MSVC and QNX) and clang's libc++ have a swap for pairs defined. + // Work around MSVC's standard library, whose swap for pairs does not swap by component. + template<typename T> inline void hashTableSwap(T& a, T& b) + { + swap(a, b); + } - // swap pairs by component, in case of pair members that specialize swap - template<typename T, typename U> inline void swap(pair<T, U>& a, pair<T, U>& b) + template<typename T, typename U> inline void hashTableSwap(pair<T, U>& a, pair<T, U>& b) { swap(a.first, b.first); swap(a.second, b.second); } -#endif template<typename T, bool useSwap> struct Mover; - template<typename T> struct Mover<T, true> { static void move(T& from, T& to) { swap(from, to); } }; + template<typename T> struct Mover<T, true> { static void move(T& from, T& to) { hashTableSwap(from, to); } }; template<typename T> struct Mover<T, false> { static void move(T& from, T& to) { to = from; } }; template<typename Key, typename Value, typename HashFunctions> class IdentityHashTranslator { diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h index 81a1d8a..7185c1b 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h @@ -28,7 +28,7 @@ #include <float.h> #include <limits> -#include <math.h> +#include <cmath> #include <stdlib.h> #if OS(SOLARIS) @@ -67,20 +67,26 @@ inline double wtf_ceil(double x) { return copysign(ceil(x), x); } #if OS(SOLARIS) +namespace std { + #ifndef isfinite inline bool isfinite(double x) { return finite(x) && !isnand(x); } #endif +#ifndef signbit +inline bool signbit(double x) { return copysign(1.0, x) < 0; } +#endif #ifndef isinf inline bool isinf(double x) { return !finite(x) && !isnand(x); } #endif -#ifndef signbit -inline bool signbit(double x) { return x < 0.0; } // FIXME: Wrong for negative 0. -#endif + +} // namespace std #endif #if OS(OPENBSD) +namespace std { + #ifndef isfinite inline bool isfinite(double x) { return finite(x); } #endif @@ -88,6 +94,8 @@ inline bool isfinite(double x) { return finite(x); } inline bool signbit(double x) { struct ieee_double *p = (struct ieee_double *)&x; return p->dbl_sign; } #endif +} // namespace std + #endif #if (COMPILER(MSVC) && _MSC_VER < 1800) || COMPILER(RVCT) @@ -115,17 +123,23 @@ inline double trunc(double num) { return num > 0 ? floor(num) : ceil(num); } #endif -#if COMPILER(MSVC) && _MSC_VER < 1800 +#if COMPILER(MSVC) + +namespace std { inline bool isinf(double num) { return !_finite(num) && !_isnan(num); } inline bool isnan(double num) { return !!_isnan(num); } +inline bool isfinite(double x) { return _finite(x); } +#if _MSC_VER < 1800 inline bool signbit(double num) { return _copysign(1.0, num) < 0; } +#endif + +} // namespace std inline double nextafter(double x, double y) { return _nextafter(x, y); } inline float nextafterf(float x, float y) { return x > y ? x - FLT_EPSILON : x + FLT_EPSILON; } inline double copysign(double x, double y) { return _copysign(x, y); } -inline int isfinite(double x) { return _finite(x); } // Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN instead of specific values. inline double wtf_atan2(double x, double y) @@ -151,10 +165,10 @@ inline double wtf_atan2(double x, double y) } // 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); } +extern "C" inline double wtf_fmod(double x, double y) { return (!std::isinf(x) && std::isinf(y)) ? x : fmod(x, y); } // Work around a bug in the Microsoft CRT, where pow(NaN, 0) yields NaN instead of 1. -inline double wtf_pow(double x, double y) { return y == 0 ? 1 : pow(x, y); } +extern "C" inline double wtf_pow(double x, double y) { return y == 0 ? 1 : pow(x, y); } #define atan2(x, y) wtf_atan2(x, y) #define fmod(x, y) wtf_fmod(x, y) @@ -185,7 +199,7 @@ inline double wtf_pow(double x, double y) { // MinGW-w64 has a custom implementation for pow. // This handles certain special cases that are different. - if ((x == 0.0 || isinf(x)) && isfinite(y)) { + if ((x == 0.0 || std::isinf(x)) && std::isfinite(y)) { double f; if (modf(y, &f) != 0.0) return ((x == 0.0) ^ (y > 0.0)) ? std::numeric_limits<double>::infinity() : 0.0; diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h index 7ba487f..3ef0f9f 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h @@ -26,6 +26,9 @@ #if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) #include <type_traits> +#if defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__) +#include <tr1/memory> +#endif #endif namespace WTF { @@ -166,13 +169,21 @@ namespace WTF { typedef T Type; }; -#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) - +#if COMPILER(CLANG) || GCC_VERSION_AT_LEAST(4, 6, 0) || (defined(_MSC_VER) && (_MSC_VER >= 1400) && (_MSC_VER < 1600) && !defined(__INTEL_COMPILER)) + // VC8 (VS2005) and later has __has_trivial_constructor and __has_trivial_destructor, + // but the implementation returns false for built-in types. We add the extra IsPod condition to + // work around this. + template <typename T> struct HasTrivialConstructor { + static const bool value = __has_trivial_constructor(T) || IsPod<RemoveConstVolatile<T> >::value; + }; + template <typename T> struct HasTrivialDestructor { + static const bool value = __has_trivial_destructor(T) || IsPod<RemoveConstVolatile<T> >::value; + }; +#elif (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) // GCC's libstdc++ 20070724 and later supports C++ TR1 type_traits in the std namespace. // VC10 (VS2010) and later support C++ TR1 type_traits in the std::tr1 namespace. template<typename T> struct HasTrivialConstructor : public std::tr1::has_trivial_constructor<T> { }; template<typename T> struct HasTrivialDestructor : public std::tr1::has_trivial_destructor<T> { }; - #else // This compiler doesn't provide type traits, so we provide basic HasTrivialConstructor @@ -189,15 +200,8 @@ namespace WTF { typedef IntegralConstant<bool, true> true_type; typedef IntegralConstant<bool, false> false_type; -#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) - // VC8 (VS2005) and later have built-in compiler support for HasTrivialConstructor / HasTrivialDestructor, - // but for some unexplained reason it doesn't work on built-in types. - template <typename T> struct HasTrivialConstructor : public IntegralConstant<bool, __has_trivial_constructor(T)>{ }; - template <typename T> struct HasTrivialDestructor : public IntegralConstant<bool, __has_trivial_destructor(T)>{ }; -#else template <typename T> struct HasTrivialConstructor : public false_type{ }; template <typename T> struct HasTrivialDestructor : public false_type{ }; -#endif template <typename T> struct HasTrivialConstructor<T*> : public true_type{ }; template <typename T> struct HasTrivialDestructor<T*> : public true_type{ }; diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/dtoa.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/dtoa.cpp index 6289d04..fe65042 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/dtoa.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/dtoa.cpp @@ -2395,7 +2395,7 @@ void doubleToStringInJavaScriptFormat(double d, DtoaBuffer buffer, unsigned* res ASSERT(buffer); // avoid ever printing -NaN, in JS conceptually there is only one NaN value - if (isnan(d)) { + if (std::isnan(d)) { append(buffer, "NaN", 3); if (resultLength) *resultLength = 3; |