2 * Copyright (C) 2010 Tim-Philipp Müller <tim centricular net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __GST_MATH_COMPAT_H__
21 #define __GST_MATH_COMPAT_H__
23 /* This header is not included automatically via gst/gst.h, you need to
24 * include it explicitly if you need it. */
26 #ifndef _USE_MATH_DEFINES
27 #define _USE_MATH_DEFINES /* so MSVC defines M_PI etc. */
35 /* http://en.wikipedia.org/wiki/Math.h */
37 #define __GST_MATH_COMPAT_NEED_RINT
38 #define __GST_MATH_COMPAT_NEED_RINTF
40 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
41 #undef __GST_MATH_COMPAT_NEED_RINT
42 #undef __GST_MATH_COMPAT_NEED_RINTF
45 #if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
46 #undef __GST_MATH_COMPAT_NEED_RINT
47 #undef __GST_MATH_COMPAT_NEED_RINTF
63 __gst_math_compat_rint (double x)
65 return floor (x + 0.5);
69 __gst_math_compat_rintf (float x)
71 return floorf (x + 0.5);
74 #if defined (__GST_MATH_COMPAT_NEED_RINT) && !defined (rint)
75 #define rint(x) __gst_math_compat_rint(x)
78 #if defined (__GST_MATH_COMPAT_NEED_RINTF) && !defined (rintf)
79 #define rintf(x) __gst_math_compat_rintf(x)
83 #if G_BYTE_ORDER == G_BIG_ENDIAN
84 #define __GST_NAN_BYTES { 0x7f, 0xc0, 0, 0 }
85 #elif G_BYTE_ORDER == G_LITTLE_ENDIAN
86 #define __GST_NAN_BYTES { 0, 0, 0xc0, 0x7f }
91 } __gst_nan_union G_GNUC_UNUSED = {
94 #define NAN (__gst_nan_union.__d)
99 #endif /* __GST_MATH_COMPAT_H__ */