]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gstreamer0-10.git/blob - gst/math-compat.h
gststructure: early out when we know a value cannot be a subset
[glsdk/gstreamer0-10.git] / gst / math-compat.h
1 /* GStreamer
2  * Copyright (C) 2010 Tim-Philipp Müller <tim centricular net>
3  *
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.
8  *
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.
13  *
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.
18  */
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. */
28 #endif
29 #include <math.h>
31 #include <glib.h>
33 G_BEGIN_DECLS
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
43 #endif
45 #if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
46 #undef __GST_MATH_COMPAT_NEED_RINT
47 #undef __GST_MATH_COMPAT_NEED_RINTF
48 #endif
50 #ifndef M_PI
51 #define M_PI G_PI
52 #endif
54 #ifndef M_PI_2
55 #define M_PI_2 G_PI_2
56 #endif
58 #ifndef M_PI_4
59 #define M_PI_4 G_PI_4
60 #endif
62 static inline double
63 __gst_math_compat_rint (double x)
64 {
65   return floor (x + 0.5);
66 }
68 static inline float
69 __gst_math_compat_rintf (float x)
70 {
71   return floorf (x + 0.5);
72 }
74 #if defined (__GST_MATH_COMPAT_NEED_RINT) && !defined (rint)
75 #define rint(x) __gst_math_compat_rint(x)
76 #endif
78 #if defined (__GST_MATH_COMPAT_NEED_RINTF) && !defined (rintf)
79 #define rintf(x) __gst_math_compat_rintf(x)
80 #endif
82 G_END_DECLS
84 #endif /* __GST_MATH_COMPAT_H__ */