Blame gst/math-compat.h

Packit f546b1
/* GStreamer
Packit f546b1
 * Copyright (C) 2010 Tim-Philipp Müller <tim centricular net>
Packit f546b1
 *
Packit f546b1
 * This library is free software; you can redistribute it and/or
Packit f546b1
 * modify it under the terms of the GNU Library General Public
Packit f546b1
 * License as published by the Free Software Foundation; either
Packit f546b1
 * version 2 of the License, or (at your option) any later version.
Packit f546b1
 *
Packit f546b1
 * This library is distributed in the hope that it will be useful,
Packit f546b1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit f546b1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit f546b1
 * Library General Public License for more details.
Packit f546b1
 *
Packit f546b1
 * You should have received a copy of the GNU Library General Public
Packit f546b1
 * License along with this library; if not, write to the
Packit f546b1
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit f546b1
 * Boston, MA 02110-1301, USA.
Packit f546b1
 */
Packit f546b1
Packit f546b1
#ifndef __GST_MATH_COMPAT_H__
Packit f546b1
#define __GST_MATH_COMPAT_H__
Packit f546b1
Packit f546b1
/* This header is not included automatically via gst/gst.h, you need to
Packit f546b1
 * include it explicitly if you need it. */
Packit f546b1
Packit f546b1
#ifndef _USE_MATH_DEFINES
Packit f546b1
#define _USE_MATH_DEFINES /* so MSVC defines M_PI etc. */
Packit f546b1
#endif
Packit f546b1
#include <math.h>
Packit f546b1
Packit f546b1
#include <glib.h>
Packit f546b1
Packit f546b1
G_BEGIN_DECLS
Packit f546b1
Packit f546b1
/* http://en.wikipedia.org/wiki/Math.h */
Packit f546b1
Packit f546b1
#define __GST_MATH_COMPAT_NEED_RINT
Packit f546b1
#define __GST_MATH_COMPAT_NEED_RINTF
Packit f546b1
#define __GST_MATH_COMPAT_NEED_ISNAN
Packit f546b1
Packit f546b1
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
Packit f546b1
#undef __GST_MATH_COMPAT_NEED_RINT
Packit f546b1
#undef __GST_MATH_COMPAT_NEED_RINTF
Packit f546b1
#undef __GST_MATH_COMPAT_NEED_ISNAN
Packit f546b1
#endif
Packit f546b1
Packit f546b1
#if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
Packit f546b1
#undef __GST_MATH_COMPAT_NEED_RINT
Packit f546b1
#undef __GST_MATH_COMPAT_NEED_RINTF
Packit f546b1
#undef __GST_MATH_COMPAT_NEED_ISNAN
Packit f546b1
#endif
Packit f546b1
Packit f546b1
#ifndef M_PI
Packit f546b1
#define M_PI G_PI
Packit f546b1
#endif
Packit f546b1
Packit f546b1
#ifndef M_PI_2
Packit f546b1
#define M_PI_2 G_PI_2
Packit f546b1
#endif
Packit f546b1
Packit f546b1
#ifndef M_PI_4
Packit f546b1
#define M_PI_4 G_PI_4
Packit f546b1
#endif
Packit f546b1
Packit f546b1
static inline double
Packit f546b1
__gst_math_compat_rint (double x)
Packit f546b1
{
Packit f546b1
  return floor (x + 0.5);
Packit f546b1
}
Packit f546b1
Packit f546b1
static inline float
Packit f546b1
__gst_math_compat_rintf (float x)
Packit f546b1
{
Packit f546b1
  return floorf (x + 0.5);
Packit f546b1
}
Packit f546b1
Packit f546b1
static inline gboolean
Packit f546b1
__gst_math_compat_isnan (double x)
Packit f546b1
{
Packit f546b1
  return x != x;
Packit f546b1
}
Packit f546b1
Packit f546b1
#if defined (__GST_MATH_COMPAT_NEED_RINT) && !defined (rint)
Packit f546b1
#define rint(x) __gst_math_compat_rint(x)
Packit f546b1
#endif
Packit f546b1
Packit f546b1
#if defined (__GST_MATH_COMPAT_NEED_RINTF) && !defined (rintf)
Packit f546b1
#define rintf(x) __gst_math_compat_rintf(x)
Packit f546b1
#endif
Packit f546b1
Packit f546b1
#if defined (__GST_MATH_COMPAT_NEED_ISNAN) && !defined (isnan)
Packit f546b1
#define isnan(x) __gst_math_compat_isnan (x)
Packit f546b1
#endif
Packit f546b1
Packit f546b1
#ifndef NAN
Packit f546b1
#if G_BYTE_ORDER == G_BIG_ENDIAN
Packit f546b1
#define __GST_NAN_BYTES        { 0x7f, 0xc0, 0, 0 }
Packit f546b1
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
Packit f546b1
#define __GST_NAN_BYTES        { 0, 0, 0xc0, 0x7f }
Packit f546b1
#endif
Packit f546b1
static union {
Packit f546b1
  unsigned char __c[4];
Packit f546b1
  float __d;
Packit f546b1
} __gst_nan_union G_GNUC_UNUSED = {
Packit f546b1
  __GST_NAN_BYTES
Packit f546b1
};
Packit f546b1
#define NAN    (__gst_nan_union.__d)
Packit f546b1
#endif
Packit f546b1
Packit f546b1
G_END_DECLS
Packit f546b1
Packit f546b1
#endif /* __GST_MATH_COMPAT_H__ */