1 /*	Public domain	*/
2 
3 #ifdef _AGAR_MATH_BEGIN_H_
4 #error Nested inclusion of <agar/math/begin.h>
5 #endif
6 #define _AGAR_MATH_BEGIN_H_
7 
8 #include <agar/core/types.h>
9 #include <agar/core/attributes.h>
10 
11 /* Define internationalization macros if NLS is enabled. */
12 #if !defined(_)
13 # include <agar/config/enable_nls.h>
14 # ifdef ENABLE_NLS
15 #  include <libintl.h>
16 #  define _(String) dgettext("agar",String)
17 #  ifdef dgettext_noop
18 #   define N_(String) dgettext_noop("agar",String)
19 #  else
20 #   define N_(String) (String)
21 #  endif
22 #  define _AGAR_MATH_DEFINED_NLS
23 # else
24 #  undef _
25 #  undef N_
26 #  undef ngettext
27 #  define _(String) (String)
28 #  define N_(String) (String)
29 #  define ngettext(Singular,Plural,Number) ((Number==1)?(Singular):(Plural))
30 #  define _AGAR_MATH_DEFINED_NLS
31 # endif
32 #endif /* defined(_) */
33 
34 /* Define __BEGIN_DECLS and __END_DECLS if needed. */
35 #if !defined(__BEGIN_DECLS) || !defined(__END_DECLS)
36 # define _AGAR_MATH_DEFINED_CDECLS
37 # if defined(__cplusplus)
38 #  define __BEGIN_DECLS extern "C" {
39 #  define __END_DECLS   }
40 # else
41 #  define __BEGIN_DECLS
42 #  define __END_DECLS
43 # endif
44 #endif
45 
46 /*
47  * Expand "DECLSPEC" to any compiler-specific keywords, as required for proper
48  * visibility of symbols in shared libraries.
49  * See: http://gcc.gnu.org/wiki/Visibility
50  */
51 #ifndef DECLSPEC
52 # if defined(__WIN32__) || defined(__WINRT__)
53 #  ifdef __BORLANDC__
54 #   ifdef _AGAR_MATH_INTERNAL
55 #    define DECLSPEC
56 #    define _AGAR_MATH_DEFINED_DECLSPEC
57 #   else
58 #    define DECLSPEC    __declspec(dllimport)
59 #    define _AGAR_MATH_DEFINED_DECLSPEC
60 #   endif
61 #  else
62 #   define DECLSPEC __declspec(dllexport)
63 #   define _AGAR_MATH_DEFINED_DECLSPEC
64 #  endif
65 # else
66 #  if defined(__GNUC__) && __GNUC__ >= 4
67 #   define DECLSPEC __attribute__ ((visibility("default")))
68 #   define _AGAR_MATH_DEFINED_DECLSPEC
69 #  elif defined(__GNUC__) && __GNUC__ >= 2
70 #   define DECLSPEC __declspec(dllexport)
71 #   define _AGAR_MATH_DEFINED_DECLSPEC
72 #  else
73 #   define DECLSPEC
74 #   define _AGAR_MATH_DEFINED_DECLSPEC
75 #  endif
76 # endif
77 #endif
78 #ifdef __SYMBIAN32__
79 #undef DECLSPEC
80 #define DECLSPEC
81 #endif /* __SYMBIAN32__ */
82 
83 /*
84  * Force structure packing at 4 byte alignment. This is necessary if the
85  * header is included in code which has structure packing set to an alternate
86  * value. The packing is reset to the previous value in close.h.
87  */
88 #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
89 # ifdef _MSC_VER
90 #  pragma warning(disable: 4103)
91 # endif
92 # ifdef __BORLANDC__
93 #  pragma nopackwarning
94 # endif
95 # pragma pack(push,4)
96 #elif (defined(__MWERKS__) && defined(__MACOS__))
97 # pragma options align=mac68k4byte
98 # pragma enumsalwaysint on
99 #endif
100 
101 /*
102  * Expand "__inline__" to any compiler-specific keyword needed for defining
103  * an inline function, if supported.
104  */
105 #ifdef __GNUC__
106 # define _AGAR_MATH_USE_INLINE
107 #else
108 # if defined(_MSC_VER) || defined(__BORLANDC__) || \
109      defined(__DMC__) || defined(__SC__) || \
110      defined(__WATCOMC__) || defined(__LCC__) || \
111      defined(__DECC) || defined(__EABI__)
112 #  ifndef __inline__
113 #   define __inline__	__inline
114 #  endif
115 #  define _AGAR_MATH_USE_INLINE
116 # else
117 #  if !defined(__MRC__) && !defined(_SGI_SOURCE)
118 #   ifndef __inline__
119 #    define __inline__ inline
120 #   endif
121 #   define _AGAR_MATH_USE_INLINE
122 #  endif
123 # endif
124 #endif /* !__GNUC__ */
125 #ifndef _AGAR_MATH_USE_INLINE
126 # define __inline__
127 #endif
128 
129 /* Define NULL if needed. */
130 #if !defined(NULL) && !defined(__MACH__)
131 # ifdef __cplusplus
132 #  define NULL 0
133 #  define _AGAR_MATH_DEFINED_NULL
134 # else
135 #  define NULL ((void *)0)
136 #  define _AGAR_MATH_DEFINED_NULL
137 # endif
138 #endif
139 
140 /* Definitions specific to Agar-MATH. */
141 #ifdef SINGLE_PRECISION
142 # define _M_UNDEFINED_SINGLE_PRECISION
143 # undef SINGLE_PRECISION
144 #endif
145 #ifdef DOUBLE_PRECISION
146 # define _M_UNDEFINED_DOUBLE_PRECISION
147 # undef DOUBLE_PRECISION
148 #endif
149 #ifdef QUAD_PRECISION
150 # define _M_UNDEFINED_QUAD_PRECISION
151 # undef QUAD_PRECISION
152 #endif
153 #include <agar/config/single_precision.h>
154 #include <agar/config/quad_precision.h>
155 #include <agar/config/double_precision.h>
156 
157 #ifdef _AGAR_MATH_INTERNAL
158 # undef MAX
159 # define MAX(h,i) ((h) > (i) ? (h) : (i))
160 # undef MIN
161 # define MIN(l,o) ((l) < (o) ? (l) : (o))
162 #endif
163