diff --git a/dmd/root/port.c b/dmd/root/port.c index f498885b..fce3c952 100644 --- a/dmd/root/port.c +++ b/dmd/root/port.c @@ -377,7 +377,11 @@ PortInitializer::PortInitializer() int Port::isNan(double r) { #if __APPLE__ +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 + return __inline_isnand(r); +#else return __inline_isnan(r); +#endif #elif __OpenBSD__ || __MINGW32__ || __HAIKU__ return isnan(r); #else @@ -389,7 +393,11 @@ int Port::isNan(double r) int Port::isNan(longdouble r) { #if __APPLE__ +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 + return __inline_isnanl(r); +#else return __inline_isnan(r); +#endif #elif __OpenBSD__ || __MINGW32__ || __HAIKU__ return isnan(r); #else diff --git a/dmd2/expression.c b/dmd2/expression.c index c898cdb9..789fd632 100644 --- a/dmd2/expression.c +++ b/dmd2/expression.c @@ -24,21 +24,9 @@ extern "C" char * __cdecl __locale_decpoint; #endif -#if __MINGW32__ -#ifndef isnan -#define isnan _isnan -#endif -#endif - -#ifdef __APPLE__ -#ifndef isnan -int isnan(double); -#endif -#endif - #include "rmem.h" -#if IN_DMD #include "port.h" +#if IN_DMD #include "root.h" #endif @@ -2416,13 +2404,7 @@ complex_t RealExp::toComplex() int RealEquals(real_t x1, real_t x2) { -// return (Port::isNan(x1) && Port::isNan(x2)) || -#if __APPLE__ - return (__inline_isnan(x1) && __inline_isnan(x2)) || -#else - return // special case nans - (isnan(x1) && isnan(x2)) || -#endif + return (Port::isNan(x1) && Port::isNan(x2)) || // and zero, in order to distinguish +0 from -0 (x1 == 0 && x2 == 0 && 1./x1 == 1./x2) || // otherwise just compare diff --git a/dmd2/root/port.c b/dmd2/root/port.c index 29b0b1e8..0beb250d 100644 --- a/dmd2/root/port.c +++ b/dmd2/root/port.c @@ -379,7 +379,11 @@ PortInitializer::PortInitializer() int Port::isNan(double r) { #if __APPLE__ +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 + return __inline_isnand(r); +#else return __inline_isnan(r); +#endif #elif defined __HAIKU__ || __OpenBSD__ return isnan(r); #else @@ -391,7 +395,11 @@ int Port::isNan(double r) int Port::isNan(longdouble r) { #if __APPLE__ +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 + return __inline_isnanl(r); +#else return __inline_isnan(r); +#endif #elif defined __HAIKU__ || __OpenBSD__ return isnan(r); #else