From 02c07aa854f5ca923105a1a16ba5807e66c50069 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 29 Jun 2012 16:52:31 +0800 Subject: [PATCH] math-compat.h: add implementation for isnan() for Visual C++ Visual C++ does not have isnan(), so add fallback to math-compat.h (could use _isnan() in this case, but this makes it work for all cases where isnan is missing). https://bugzilla.gnome.org/show_bug.cgi?id=679112 --- gst/math-compat.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gst/math-compat.h b/gst/math-compat.h index aa123db0a8..d160c2cff7 100644 --- a/gst/math-compat.h +++ b/gst/math-compat.h @@ -36,15 +36,18 @@ G_BEGIN_DECLS #define __GST_MATH_COMPAT_NEED_RINT #define __GST_MATH_COMPAT_NEED_RINTF +#define __GST_MATH_COMPAT_NEED_ISNAN #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #undef __GST_MATH_COMPAT_NEED_RINT #undef __GST_MATH_COMPAT_NEED_RINTF +#undef __GST_MATH_COMPAT_NEED_ISNAN #endif #if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L #undef __GST_MATH_COMPAT_NEED_RINT #undef __GST_MATH_COMPAT_NEED_RINTF +#undef __GST_MATH_COMPAT_NEED_ISNAN #endif #ifndef M_PI @@ -71,6 +74,12 @@ __gst_math_compat_rintf (float x) return floorf (x + 0.5); } +static inline gboolean +__gst_math_compat_isnan (double x) +{ + return x != x; +} + #if defined (__GST_MATH_COMPAT_NEED_RINT) && !defined (rint) #define rint(x) __gst_math_compat_rint(x) #endif @@ -79,6 +88,10 @@ __gst_math_compat_rintf (float x) #define rintf(x) __gst_math_compat_rintf(x) #endif +#if defined (__GST_MATH_COMPAT_NEED_ISNAN) && !defined (isnan) +#define isnan(x) __gst_math_compat_isnan (x) +#endif + #ifndef NAN #if G_BYTE_ORDER == G_BIG_ENDIAN #define __GST_NAN_BYTES { 0x7f, 0xc0, 0, 0 } -- 2.34.1