From e8f213c2a89e069f5a1125a38094f399a4416e12 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 20 Oct 2016 19:18:29 +0200 Subject: compat/nan: fix isnan in presence of -ffast-math The trick prevents GCC isnan builtin from getting called. --- compat/nan.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/compat/nan.cpp b/compat/nan.cpp index 899b907a..a7b37362 100644 --- a/compat/nan.cpp +++ b/compat/nan.cpp @@ -1,17 +1,16 @@ -#include #include "export.hpp" -#if defined(__GNUC__) -extern "C" OPENTRACK_COMPAT_EXPORT bool __attribute__ ((noinline)) nanp(double value) -#elif defined(_WIN32) -extern "C" OPENTRACK_COMPAT_EXPORT __declspec(noinline) bool nanp(double value) +#if defined(_MSC_VER) +# include +# define my_isnan std::isnan +# define my_isinf std::isinf +extern "C" OPENTRACK_COMPAT_EXPORT __declspec(noinline) bool nanp(double x) #else -extern "C" OPENTRACK_COMPAT_EXPORT bool nanp(double value) +int my_isnan(double)__asm__("isnan"); +int my_isinf(double)__asm__("isinf"); + +extern "C" OPENTRACK_COMPAT_EXPORT bool __attribute__ ((noinline)) nanp(double x) #endif { - using std::isnan; - using std::isinf; - - const volatile double x = value; - return isnan(x) || isinf(x); + return my_isnan(x) || my_isinf(x); } -- cgit v1.2.3