Commit 9182d475 authored by zandobersek@gmail.com's avatar zandobersek@gmail.com

The 'global isinf/isnan' compiler quirk required when using clang with libstdc++

https://bugs.webkit.org/show_bug.cgi?id=109325

Reviewed by Anders Carlsson.

Prefix calls to the isinf and isnan methods with std::, declaring we want to use the
two methods as they're provided by the C++ standard library being used.

Source/JavaScriptCore: 

* API/JSValueRef.cpp:
(JSValueMakeNumber):
* JSCTypedArrayStubs.h:
(JSC):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitLoad):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::constantNaN):
* offlineasm/cloop.rb:
* runtime/DateConstructor.cpp:
(JSC::dateUTC): Also include an opportunistic style fix.
* runtime/DateInstance.cpp:
(JSC::DateInstance::calculateGregorianDateTime):
(JSC::DateInstance::calculateGregorianDateTimeUTC):
* runtime/DatePrototype.cpp:
(JSC::dateProtoFuncGetMilliSeconds):
(JSC::dateProtoFuncGetUTCMilliseconds):
(JSC::setNewValueFromTimeArgs):
(JSC::setNewValueFromDateArgs):
(JSC::dateProtoFuncSetYear):
* runtime/JSCJSValue.cpp:
(JSC::JSValue::toInteger):
* runtime/JSDateMath.cpp:
(JSC::getUTCOffset):
(JSC::parseDateFromNullTerminatedCharacters):
(JSC::parseDate):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncIsNaN):
* runtime/MathObject.cpp:
(JSC::mathProtoFuncMax):
(JSC::mathProtoFuncMin):
(JSC::mathProtoFuncPow):
* runtime/PropertyDescriptor.cpp:
(JSC::sameValue):

Source/WebCore: 

No new tests as there's no change in functionality.

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::setDuration):
* Modules/webaudio/AudioBufferSourceNode.cpp:
(WebCore::AudioBufferSourceNode::totalPitchRate):
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::setValue):
* Modules/webaudio/AudioParamTimeline.cpp:
(WebCore::isValidNumber):
* Modules/webaudio/PannerNode.cpp:
(WebCore::fixNANs):
* bindings/js/IDBBindingUtilities.cpp:
(WebCore::createIDBKeyFromValue):
* bindings/js/JSDataViewCustom.cpp:
(WebCore::getDataViewMember):
* bindings/js/JSGeolocationCustom.cpp:
(WebCore::setTimeout):
(WebCore::setMaximumAge):
* bindings/js/JSHTMLOptionsCollectionCustom.cpp:
(WebCore::JSHTMLOptionsCollection::setLength):
* bindings/js/JSWebKitPointCustom.cpp:
(WebCore::JSWebKitPointConstructor::constructJSWebKitPoint):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
(GenerateParametersCheck):
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateParametersCheck):
* bindings/scripts/test/JS/JSFloat64Array.cpp:
(WebCore::JSFloat64Array::getByIndex):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionClassMethodWithClamp):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjV8Internal::classMethodWithClampCallback):
* bindings/v8/IDBBindingUtilities.cpp:
(WebCore::createIDBKeyFromValue):
* bindings/v8/V8Binding.cpp:
(WebCore::toInt32):
(WebCore::toUInt32):
* bindings/v8/custom/V8GeolocationCustom.cpp:
(WebCore::createPositionOptions):
* bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:
(WebCore::V8HTMLOptionsCollection::lengthAccessorSetter):
* bindings/v8/custom/V8WebKitPointCustom.cpp:
(WebCore::V8WebKitPoint::constructorCallbackCustom):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::convertValueToQVariant):
* css/WebKitCSSMatrix.cpp:
(WebCore::WebKitCSSMatrix::translate):
(WebCore::WebKitCSSMatrix::scale):
(WebCore::WebKitCSSMatrix::rotate):
(WebCore::WebKitCSSMatrix::rotateAxisAngle):
(WebCore::WebKitCSSMatrix::skewX):
(WebCore::WebKitCSSMatrix::skewY):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::percentLoaded):
(WebCore::HTMLMediaElement::mediaPlayerTimeChanged):
(WebCore::HTMLMediaElement::endedPlayback):
* html/MediaController.cpp:
(MediaController::duration):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::clearColor):
* html/track/TextTrack.cpp:
(WebCore::TextTrack::addCue):
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::setStartTime):
(WebCore::TextTrackCue::setEndTime):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::adjustWindowRect):
* page/WindowFeatures.cpp:
(WebCore::WindowFeatures::floatFeature): Also include an opportunistic style fix.
* platform/CalculationValue.cpp:
(WebCore::CalculationValue::evaluate):
* platform/Decimal.cpp:
(WebCore::Decimal::fromDouble):
* platform/Length.cpp:
(WebCore::Length::nonNanCalculatedValue):
* platform/audio/AudioResampler.cpp:
(WebCore::AudioResampler::setRate):
* platform/audio/DynamicsCompressorKernel.cpp:
(WebCore::DynamicsCompressorKernel::process):
* platform/audio/Reverb.cpp:
(WebCore::calculateNormalizationScale):
* platform/graphics/Font.cpp:
(WebCore::Font::width):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
(WebCore::MediaPlayerPrivateAVFoundation::isLiveStream):
* platform/graphics/gpu/LoopBlinnMathUtils.cpp:
(LoopBlinnMathUtils):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::buffered):
(WebCore::MediaPlayerPrivateGStreamer::maxTimeSeekable):
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::MediaPlayerPrivateQTKit::maxTimeSeekable):
* platform/graphics/opentype/OpenTypeVerticalData.cpp:
(WebCore::OpenTypeVerticalData::getVerticalTranslationsForGlyphs):
* platform/graphics/transforms/TransformationMatrix.cpp:
(WebCore::clampEdgeValue):
(WebCore::TransformationMatrix::clampedBoundsOfProjectedQuad):
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::parseCacheControlDirectives):
* rendering/RenderMediaControlsChromium.cpp:
(WebCore::paintMediaSlider):
(WebCore::paintMediaVolumeSlider):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintMediaSliderTrack):
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::beginElementAt):
(WebCore::SVGAnimationElement::endElementAt):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::setCurrentTime):
* svg/animation/SMILTime.h:
(WebCore::SMILTime::SMILTime):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::addBeginTime):
(WebCore::SVGSMILElement::addEndTime):
* xml/XPathFunctions.cpp:
(WebCore::XPath::FunSubstring::evaluate):
(WebCore::XPath::FunRound::round):
* xml/XPathValue.cpp:
(WebCore::XPath::Value::toBoolean): Also include an opportunistic style fix.
(WebCore::XPath::Value::toString):

Source/WebKit/chromium: 

* tests/DecimalTest.cpp:
(TEST_F):

Source/WebKit/mac: 

* tests/DecimalTest.cpp:
(TEST_F):

Source/WTF: 

* wtf/Compiler.h: Remove the global isinf/isnan compiler quirk definitions. They're not required anymore.
* wtf/DateMath.cpp: Move the workaround for isinf on Solaris into the std namespace. Ditto for isinf and isnan
when using MSVC. Stop bringing the isinf and isnan methods into the global scope when using other configurations.
(WTF::parseDateFromNullTerminatedCharacters):
* wtf/IntegralTypedArrayBase.h:
(WTF::IntegralTypedArrayBase::set):
* wtf/MathExtras.h:
(std):
(std::isinf):
(wtf_fmod):
(wtf_pow):
(doubleToInteger):
* wtf/MediaTime.cpp:
(WTF::MediaTime::createWithFloat):
(WTF::MediaTime::createWithDouble):
* wtf/Uint8ClampedArray.h:
(WTF::Uint8ClampedArray::set):

Tools: 

* DumpRenderTree/TestRunner.cpp:
(setAppCacheMaximumSizeCallback):
(setApplicationCacheOriginQuotaCallback):
(setDatabaseQuotaCallback):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@142810 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 70109507
......@@ -231,7 +231,7 @@ JSValueRef JSValueMakeNumber(JSContextRef ctx, double value)
// Our JSValue representation relies on a standard bit pattern for NaN. NaNs
// generated internally to JavaScriptCore naturally have that representation,
// but an external NaN might not.
if (isnan(value))
if (std::isnan(value))
value = QNaN;
return toRef(exec, jsNumber(value));
......
2013-02-13 Zan Dobersek <zdobersek@igalia.com>
The 'global isinf/isnan' compiler quirk required when using clang with libstdc++
https://bugs.webkit.org/show_bug.cgi?id=109325
Reviewed by Anders Carlsson.
Prefix calls to the isinf and isnan methods with std::, declaring we want to use the
two methods as they're provided by the C++ standard library being used.
* API/JSValueRef.cpp:
(JSValueMakeNumber):
* JSCTypedArrayStubs.h:
(JSC):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitLoad):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::constantNaN):
* offlineasm/cloop.rb:
* runtime/DateConstructor.cpp:
(JSC::dateUTC): Also include an opportunistic style fix.
* runtime/DateInstance.cpp:
(JSC::DateInstance::calculateGregorianDateTime):
(JSC::DateInstance::calculateGregorianDateTimeUTC):
* runtime/DatePrototype.cpp:
(JSC::dateProtoFuncGetMilliSeconds):
(JSC::dateProtoFuncGetUTCMilliseconds):
(JSC::setNewValueFromTimeArgs):
(JSC::setNewValueFromDateArgs):
(JSC::dateProtoFuncSetYear):
* runtime/JSCJSValue.cpp:
(JSC::JSValue::toInteger):
* runtime/JSDateMath.cpp:
(JSC::getUTCOffset):
(JSC::parseDateFromNullTerminatedCharacters):
(JSC::parseDate):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncIsNaN):
* runtime/MathObject.cpp:
(JSC::mathProtoFuncMax):
(JSC::mathProtoFuncMin):
(JSC::mathProtoFuncPow):
* runtime/PropertyDescriptor.cpp:
(JSC::sameValue):
2013-02-13 Filip Pizlo <fpizlo@apple.com>
Change another use of (SpecCell & ~SpecString) to SpecObject.
......
......@@ -174,7 +174,7 @@ JSValue JS##name##Array::getByIndex(ExecState*, unsigned index)\
{\
ASSERT_GC_OBJECT_INHERITS(this, &s_info);\
type result = m_impl->item(index);\
if (isnan((double)result))\
if (std::isnan((double)result))\
return jsNaN();\
return JSValue(result);\
}\
......
......@@ -1247,7 +1247,7 @@ RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, double number)
// FIXME: Our hash tables won't hold infinity, so we make a new JSValue each time.
// Later we can do the extra work to handle that like the other cases. They also don't
// work correctly with NaN as a key.
if (isnan(number) || number == HashTraits<double>::emptyValue() || HashTraits<double>::isDeletedValue(number))
if (std::isnan(number) || number == HashTraits<double>::emptyValue() || HashTraits<double>::isDeletedValue(number))
return emitLoad(dst, jsNumber(number));
JSValue& valueInMap = m_numberMap.add(number, JSValue()).iterator->value;
if (!valueInMap)
......
......@@ -656,7 +656,7 @@ private:
// m_constantNaN must refer to an entry in the CodeBlock's constant pool that has the value nan.
ASSERT(m_codeBlock->getConstant(FirstConstantRegisterIndex + m_constantNaN).isDouble());
ASSERT(isnan(m_codeBlock->getConstant(FirstConstantRegisterIndex + m_constantNaN).asDouble()));
ASSERT(std::isnan(m_codeBlock->getConstant(FirstConstantRegisterIndex + m_constantNaN).asDouble()));
return getJSConstant(m_constantNaN);
}
......
......@@ -398,7 +398,7 @@ def cloopEmitUnaryOperation(operands, type, operator)
end
def cloopEmitCompareDoubleWithNaNCheckAndBranch(operands, condition)
$asm.putc "if (isnan(#{operands[0].clValue(:double)}) || isnan(#{operands[1].clValue(:double)})"
$asm.putc "if (std::isnan(#{operands[0].clValue(:double)}) || isnan(#{operands[1].clValue(:double)})"
$asm.putc " || (#{operands[0].clValue(:double)} #{condition} #{operands[1].clValue(:double)}))"
$asm.putc " goto #{operands[2].cLabel};"
end
......
......@@ -199,13 +199,13 @@ static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState* exec)
exec->argument(6).toNumber(exec)
};
int n = exec->argumentCount();
if (isnan(doubleArguments[0])
|| isnan(doubleArguments[1])
|| (n >= 3 && isnan(doubleArguments[2]))
|| (n >= 4 && isnan(doubleArguments[3]))
|| (n >= 5 && isnan(doubleArguments[4]))
|| (n >= 6 && isnan(doubleArguments[5]))
|| (n >= 7 && isnan(doubleArguments[6])))
if (std::isnan(doubleArguments[0])
|| std::isnan(doubleArguments[1])
|| (n >= 3 && std::isnan(doubleArguments[2]))
|| (n >= 4 && std::isnan(doubleArguments[3]))
|| (n >= 5 && std::isnan(doubleArguments[4]))
|| (n >= 6 && std::isnan(doubleArguments[5]))
|| (n >= 7 && std::isnan(doubleArguments[6])))
return JSValue::encode(jsNaN());
GregorianDateTime t;
......
......@@ -61,7 +61,7 @@ void DateInstance::destroy(JSCell* cell)
const GregorianDateTime* DateInstance::calculateGregorianDateTime(ExecState* exec) const
{
double milli = internalNumber();
if (isnan(milli))
if (std::isnan(milli))
return 0;
if (!m_data)
......@@ -77,7 +77,7 @@ const GregorianDateTime* DateInstance::calculateGregorianDateTime(ExecState* exe
const GregorianDateTime* DateInstance::calculateGregorianDateTimeUTC(ExecState* exec) const
{
double milli = internalNumber();
if (isnan(milli))
if (std::isnan(milli))
return 0;
if (!m_data)
......
......@@ -834,7 +834,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetMilliSeconds(ExecState* exec)
DateInstance* thisDateObj = asDateInstance(thisValue);
double milli = thisDateObj->internalNumber();
if (isnan(milli))
if (std::isnan(milli))
return JSValue::encode(jsNaN());
double secs = floor(milli / msPerSecond);
......@@ -850,7 +850,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncGetUTCMilliseconds(ExecState* exec)
DateInstance* thisDateObj = asDateInstance(thisValue);
double milli = thisDateObj->internalNumber();
if (isnan(milli))
if (std::isnan(milli))
return JSValue::encode(jsNaN());
double secs = floor(milli / msPerSecond);
......@@ -895,7 +895,7 @@ static EncodedJSValue setNewValueFromTimeArgs(ExecState* exec, int numArgsToUse,
DateInstance* thisDateObj = asDateInstance(thisValue);
double milli = thisDateObj->internalNumber();
if (!exec->argumentCount() || isnan(milli)) {
if (!exec->argumentCount() || std::isnan(milli)) {
JSValue result = jsNaN();
thisDateObj->setInternalValue(exec->globalData(), result);
return JSValue::encode(result);
......@@ -940,7 +940,7 @@ static EncodedJSValue setNewValueFromDateArgs(ExecState* exec, int numArgsToUse,
double ms = 0;
GregorianDateTime gregorianDateTime;
if (numArgsToUse == 3 && isnan(milli))
if (numArgsToUse == 3 && std::isnan(milli))
msToGregorianDateTime(exec, 0, true, gregorianDateTime);
else {
ms = milli - floor(milli / msPerSecond) * msPerSecond;
......@@ -1064,7 +1064,7 @@ EncodedJSValue JSC_HOST_CALL dateProtoFuncSetYear(ExecState* exec)
double ms = 0;
GregorianDateTime gregorianDateTime;
if (isnan(milli))
if (std::isnan(milli))
// Based on ECMA 262 B.2.5 (setYear)
// the time must be reset to +0 if it is NaN.
msToGregorianDateTime(exec, 0, true, gregorianDateTime);
......
......@@ -46,7 +46,7 @@ double JSValue::toInteger(ExecState* exec) const
if (isInt32())
return asInt32();
double d = toNumber(exec);
return isnan(d) ? 0.0 : trunc(d);
return std::isnan(d) ? 0.0 : trunc(d);
}
double JSValue::toIntegerPreserveNaN(ExecState* exec) const
......
......@@ -196,7 +196,7 @@ static double getDSTOffset(ExecState* exec, double ms, double utcOffset)
double getUTCOffset(ExecState* exec)
{
double utcOffset = exec->globalData().cachedUTCOffset;
if (!isnan(utcOffset))
if (!std::isnan(utcOffset))
return utcOffset;
exec->globalData().cachedUTCOffset = calculateUTCOffset();
return exec->globalData().cachedUTCOffset;
......@@ -247,7 +247,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 QNaN;
// fall back to local timezone
......@@ -264,7 +264,7 @@ double parseDate(ExecState* exec, const String& date)
if (date == exec->globalData().cachedDateString)
return exec->globalData().cachedDateStringValue;
double value = parseES5DateFromNullTerminatedCharacters(date.utf8().data());
if (isnan(value))
if (std::isnan(value))
value = parseDateFromNullTerminatedCharacters(exec, date.utf8().data());
exec->globalData().cachedDateString = date;
exec->globalData().cachedDateStringValue = value;
......
......@@ -560,7 +560,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec)
EncodedJSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec)
{
return JSValue::encode(jsBoolean(isnan(exec->argument(0).toNumber(exec))));
return JSValue::encode(jsBoolean(std::isnan(exec->argument(0).toNumber(exec))));
}
EncodedJSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec)
......
......@@ -174,7 +174,7 @@ EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec)
double result = -std::numeric_limits<double>::infinity();
for (unsigned k = 0; k < argsCount; ++k) {
double val = exec->argument(k).toNumber(exec);
if (isnan(val)) {
if (std::isnan(val)) {
result = QNaN;
break;
}
......@@ -190,7 +190,7 @@ EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec)
double result = +std::numeric_limits<double>::infinity();
for (unsigned k = 0; k < argsCount; ++k) {
double val = exec->argument(k).toNumber(exec);
if (isnan(val)) {
if (std::isnan(val)) {
result = QNaN;
break;
}
......@@ -244,9 +244,9 @@ EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec)
double arg = exec->argument(0).toNumber(exec);
double arg2 = exec->argument(1).toNumber(exec);
if (isnan(arg2))
if (std::isnan(arg2))
return JSValue::encode(jsNaN());
if (isinf(arg2) && fabs(arg) == 1)
if (std::isinf(arg2) && fabs(arg) == 1)
return JSValue::encode(jsNaN());
return JSValue::encode(jsNumber(mathPow(arg, arg2)));
}
......
......@@ -176,8 +176,8 @@ bool sameValue(ExecState* exec, JSValue a, JSValue b)
return false;
double x = a.asNumber();
double y = b.asNumber();
if (isnan(x))
return isnan(y);
if (std::isnan(x))
return std::isnan(y);
return bitwise_cast<uint64_t>(x) == bitwise_cast<uint64_t>(y);
}
......
2013-02-13 Zan Dobersek <zdobersek@igalia.com>
The 'global isinf/isnan' compiler quirk required when using clang with libstdc++
https://bugs.webkit.org/show_bug.cgi?id=109325
Reviewed by Anders Carlsson.
Prefix calls to the isinf and isnan methods with std::, declaring we want to use the
two methods as they're provided by the C++ standard library being used.
* wtf/Compiler.h: Remove the global isinf/isnan compiler quirk definitions. They're not required anymore.
* wtf/DateMath.cpp: Move the workaround for isinf on Solaris into the std namespace. Ditto for isinf and isnan
when using MSVC. Stop bringing the isinf and isnan methods into the global scope when using other configurations.
(WTF::parseDateFromNullTerminatedCharacters):
* wtf/IntegralTypedArrayBase.h:
(WTF::IntegralTypedArrayBase::set):
* wtf/MathExtras.h:
(std):
(std::isinf):
(wtf_fmod):
(wtf_pow):
(doubleToInteger):
* wtf/MediaTime.cpp:
(WTF::MediaTime::createWithFloat):
(WTF::MediaTime::createWithDouble):
* wtf/Uint8ClampedArray.h:
(WTF::Uint8ClampedArray::set):
2013-02-13 Eric Seidel <eric@webkit.org>
Don't copy Vector<UChar> when passing to new String methods from bug 109617
......
......@@ -128,11 +128,9 @@
#define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS 1
#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL 1
#define WTF_COMPILER_QUIRK_GCC11_GLOBAL_ISINF_ISNAN 1
#elif GCC_VERSION_AT_LEAST(4, 6, 0) && defined(__GXX_EXPERIMENTAL_CXX0X__)
#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
#define WTF_COMPILER_QUIRK_GCC11_GLOBAL_ISINF_ISNAN 1
#endif
#endif
......
......@@ -1058,7 +1058,7 @@ double parseDateFromNullTerminatedCharacters(const char* dateString)
bool haveTZ;
int offset;
double ms = parseDateFromNullTerminatedCharacters(dateString, haveTZ, offset);
if (isnan(ms))
if (std::isnan(ms))
return std::numeric_limits<double>::quiet_NaN();
// fall back to local timezone
......
......@@ -43,7 +43,7 @@ class IntegralTypedArrayBase : public TypedArrayBase<T> {
{
if (index >= TypedArrayBase<T>::m_length)
return;
if (isnan(value)) // Clamp NaN to 0
if (std::isnan(value)) // Clamp NaN to 0
value = 0;
// The double cast is necessary to get the correct wrapping
// for out-of-range values with Int32Array and Uint32Array.
......
......@@ -88,13 +88,18 @@ inline double wtf_ceil(double x) { return copysign(ceil(x), x); }
#ifndef isfinite
inline bool isfinite(double x) { return finite(x) && !isnand(x); }
#endif
#ifndef isinf
inline bool isinf(double x) { return !finite(x) && !isnand(x); }
#endif
#ifndef signbit
inline bool signbit(double x) { return copysign(1.0, x) < 0; }
#endif
namespace std {
#ifndef isinf
inline bool isinf(double x) { return !finite(x) && !isnand(x); }
#endif
} // namespace std
#endif
#if OS(OPENBSD)
......@@ -159,8 +164,13 @@ inline float log2f(float num)
inline long long abs(long long num) { return _abs64(num); }
#endif
namespace std {
inline bool isinf(double num) { return !_finite(num) && !_isnan(num); }
inline bool isnan(double num) { return !!_isnan(num); }
} // namespace std
inline bool signbit(double num) { return _copysign(1.0, num) < 0; }
inline double nextafter(double x, double y) { return _nextafter(x, y); }
......@@ -193,7 +203,7 @@ 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); }
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); }
......@@ -331,29 +341,9 @@ template<typename T> inline T timesThreePlusOneDividedByTwo(T value)
#if !COMPILER(MSVC) && !COMPILER(RVCT) && !OS(SOLARIS)
using std::isfinite;
#if !COMPILER_QUIRK(GCC11_GLOBAL_ISINF_ISNAN)
using std::isinf;
using std::isnan;
#endif
using std::signbit;
#endif
#if COMPILER_QUIRK(GCC11_GLOBAL_ISINF_ISNAN)
// A workaround to avoid conflicting declarations of isinf and isnan when compiling with GCC in C++11 mode.
namespace std {
inline bool wtf_isinf(float f) { return std::isinf(f); }
inline bool wtf_isinf(double d) { return std::isinf(d); }
inline bool wtf_isnan(float f) { return std::isnan(f); }
inline bool wtf_isnan(double d) { return std::isnan(d); }
};
using std::wtf_isinf;
using std::wtf_isnan;
#define isinf(x) wtf_isinf(x)
#define isnan(x) wtf_isnan(x)
#endif
#ifndef UINT64_C
#if COMPILER(MSVC)
#define UINT64_C(c) c ## ui64
......@@ -367,7 +357,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)) && isfinite(y)) {
double f;
if (modf(y, &f) != 0.0)
return ((x == 0.0) ^ (y > 0.0)) ? std::numeric_limits<double>::infinity() : 0.0;
......@@ -409,7 +399,7 @@ inline void decomposeDouble(double number, bool& sign, int32_t& exponent, uint64
// Calculate d % 2^{64}.
inline void doubleToInteger(double d, unsigned long long& value)
{
if (isnan(d) || isinf(d))
if (std::isnan(d) || std::isinf(d))
value = 0;
else {
// -2^{64} < fmodValue < 2^{64}.
......
......@@ -83,7 +83,7 @@ MediaTime MediaTime::createWithFloat(float floatTime, int32_t timeScale)
{
if (floatTime != floatTime)
return invalidTime();
if (isinf(floatTime))
if (std::isinf(floatTime))
return signbit(floatTime) ? negativeInfiniteTime() : positiveInfiniteTime();
if (floatTime > numeric_limits<int64_t>::max())
return positiveInfiniteTime();
......@@ -99,7 +99,7 @@ MediaTime MediaTime::createWithDouble(double doubleTime, int32_t timeScale)
{
if (doubleTime != doubleTime)
return invalidTime();
if (isinf(doubleTime))
if (std::isinf(doubleTime))
return signbit(doubleTime) ? negativeInfiniteTime() : positiveInfiniteTime();
if (doubleTime > numeric_limits<int64_t>::max())
return positiveInfiniteTime();
......
......@@ -99,7 +99,7 @@ void Uint8ClampedArray::set(unsigned index, double value)
{
if (index >= m_length)
return;
if (isnan(value) || value < 0)
if (std::isnan(value) || value < 0)
value = 0;
else if (value > 255)
value = 255;
......
2013-02-13 Zan Dobersek <zdobersek@igalia.com>
The 'global isinf/isnan' compiler quirk required when using clang with libstdc++
https://bugs.webkit.org/show_bug.cgi?id=109325
Reviewed by Anders Carlsson.
Prefix calls to the isinf and isnan methods with std::, declaring we want to use the
two methods as they're provided by the C++ standard library being used.
No new tests as there's no change in functionality.
* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::setDuration):
* Modules/webaudio/AudioBufferSourceNode.cpp:
(WebCore::AudioBufferSourceNode::totalPitchRate):
* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::setValue):
* Modules/webaudio/AudioParamTimeline.cpp:
(WebCore::isValidNumber):
* Modules/webaudio/PannerNode.cpp:
(WebCore::fixNANs):
* bindings/js/IDBBindingUtilities.cpp:
(WebCore::createIDBKeyFromValue):
* bindings/js/JSDataViewCustom.cpp:
(WebCore::getDataViewMember):
* bindings/js/JSGeolocationCustom.cpp:
(WebCore::setTimeout):
(WebCore::setMaximumAge):
* bindings/js/JSHTMLOptionsCollectionCustom.cpp:
(WebCore::JSHTMLOptionsCollection::setLength):
* bindings/js/JSWebKitPointCustom.cpp:
(WebCore::JSWebKitPointConstructor::constructJSWebKitPoint):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
(GenerateParametersCheck):
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateParametersCheck):
* bindings/scripts/test/JS/JSFloat64Array.cpp:
(WebCore::JSFloat64Array::getByIndex):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionClassMethodWithClamp):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjV8Internal::classMethodWithClampCallback):
* bindings/v8/IDBBindingUtilities.cpp:
(WebCore::createIDBKeyFromValue):
* bindings/v8/V8Binding.cpp:
(WebCore::toInt32):
(WebCore::toUInt32):
* bindings/v8/custom/V8GeolocationCustom.cpp:
(WebCore::createPositionOptions):
* bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:
(WebCore::V8HTMLOptionsCollection::lengthAccessorSetter):
* bindings/v8/custom/V8WebKitPointCustom.cpp:
(WebCore::V8WebKitPoint::constructorCallbackCustom):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::convertValueToQVariant):
* css/WebKitCSSMatrix.cpp:
(WebCore::WebKitCSSMatrix::translate):
(WebCore::WebKitCSSMatrix::scale):
(WebCore::WebKitCSSMatrix::rotate):
(WebCore::WebKitCSSMatrix::rotateAxisAngle):
(WebCore::WebKitCSSMatrix::skewX):
(WebCore::WebKitCSSMatrix::skewY):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::percentLoaded):
(WebCore::HTMLMediaElement::mediaPlayerTimeChanged):
(WebCore::HTMLMediaElement::endedPlayback):
* html/MediaController.cpp:
(MediaController::duration):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::clearColor):
* html/track/TextTrack.cpp:
(WebCore::TextTrack::addCue):
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::setStartTime):
(WebCore::TextTrackCue::setEndTime):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::adjustWindowRect):
* page/WindowFeatures.cpp:
(WebCore::WindowFeatures::floatFeature): Also include an opportunistic style fix.
* platform/CalculationValue.cpp:
(WebCore::CalculationValue::evaluate):
* platform/Decimal.cpp:
(WebCore::Decimal::fromDouble):
* platform/Length.cpp:
(WebCore::Length::nonNanCalculatedValue):
* platform/audio/AudioResampler.cpp:
(WebCore::AudioResampler::setRate):
* platform/audio/DynamicsCompressorKernel.cpp:
(WebCore::DynamicsCompressorKernel::process):
* platform/audio/Reverb.cpp:
(WebCore::calculateNormalizationScale):
* platform/graphics/Font.cpp:
(WebCore::Font::width):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
(WebCore::MediaPlayerPrivateAVFoundation::isLiveStream):
* platform/graphics/gpu/LoopBlinnMathUtils.cpp:
(LoopBlinnMathUtils):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::buffered):
(WebCore::MediaPlayerPrivateGStreamer::maxTimeSeekable):
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::MediaPlayerPrivateQTKit::maxTimeSeekable):
* platform/graphics/opentype/OpenTypeVerticalData.cpp:
(WebCore::OpenTypeVerticalData::getVerticalTranslationsForGlyphs):
* platform/graphics/transforms/TransformationMatrix.cpp:
(WebCore::clampEdgeValue):
(WebCore::TransformationMatrix::clampedBoundsOfProjectedQuad):
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::parseCacheControlDirectives):
* rendering/RenderMediaControlsChromium.cpp:
(WebCore::paintMediaSlider):
(WebCore::paintMediaVolumeSlider):
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::paintMediaSliderTrack):
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::beginElementAt):
(WebCore::SVGAnimationElement::endElementAt):
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::setCurrentTime):
* svg/animation/SMILTime.h:
(WebCore::SMILTime::SMILTime):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::addBeginTime):
(WebCore::SVGSMILElement::addEndTime):
* xml/XPathFunctions.cpp:
(WebCore::XPath::FunSubstring::evaluate):
(WebCore::XPath::FunRound::round):
* xml/XPathValue.cpp:
(WebCore::XPath::Value::toBoolean): Also include an opportunistic style fix.
(WebCore::XPath::Value::toString):
2013-02-13 Eric Carlson <eric.carlson@apple.com>
[Mac] Caption menu should have only one item selected
......@@ -93,7 +93,7 @@ double MediaSource::duration() const
void MediaSource::setDuration(double duration, ExceptionCode& ec)
{
if (duration < 0.0 || isnan(duration)) {
if (duration < 0.0 || std::isnan(duration)) {