[CSRSRV]: Fix two DPRINTs.
[reactos.git] / reactos / include / crt / math.h
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the w64 mingw-runtime package.
4 * No warranty is given; refer to the file DISCLAIMER within this package.
5 */
6 #ifndef _INC_MATH
7 #define _INC_MATH
8
9 #include "crtdefs.h"
10
11 struct _exception;
12
13 #pragma pack(push,_CRT_PACKING)
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 #if defined(__GNUC__)
20 /* Some 3rd party code needs the declaration of C99 functions */
21 #include "mingw_math.h"
22 #endif
23
24 #ifndef _EXCEPTION_DEFINED
25 #define _EXCEPTION_DEFINED
26 struct _exception {
27 int type;
28 char *name;
29 double arg1;
30 double arg2;
31 double retval;
32 };
33 #endif
34
35 #ifndef _COMPLEX_DEFINED
36 #define _COMPLEX_DEFINED
37 struct _complex {
38 double x,y;
39 };
40 #endif
41
42 #define _DOMAIN 1
43 #define _SING 2
44 #define _OVERFLOW 3
45 #define _UNDERFLOW 4
46 #define _TLOSS 5
47 #define _PLOSS 6
48 #define EDOM 33
49 #define ERANGE 34
50
51 _CRTIMP extern double _HUGE;
52
53 #define HUGE_VAL _HUGE
54 #define _matherrl _matherr
55
56 #ifndef _CRT_ABS_DEFINED
57 #define _CRT_ABS_DEFINED
58 int __cdecl abs(_In_ int x);
59 long __cdecl labs(_In_ long x);
60 #endif
61
62 double __cdecl acos(_In_ double x);
63 double __cdecl asin(_In_ double x);
64 double __cdecl atan(_In_ double x);
65 double __cdecl atan2(_In_ double y, _In_ double x);
66 double __cdecl cos(_In_ double x);
67 double __cdecl cosh(_In_ double x);
68 double __cdecl exp(_In_ double x);
69 double __cdecl fabs(_In_ double x);
70 double __cdecl fmod(_In_ double x, _In_ double y);
71 double __cdecl log(_In_ double x);
72 double __cdecl log10(_In_ double x);
73 double __cdecl pow(_In_ double x, double y);
74 double __cdecl sin(_In_ double x);
75 double __cdecl sinh(_In_ double x);
76 double __cdecl sqrt(_In_ double x);
77 double __cdecl tan(_In_ double x);
78 double __cdecl tanh(_In_ double x);
79
80 #ifndef _CRT_MATHERR_DEFINED
81 #define _CRT_MATHERR_DEFINED
82 int __cdecl _matherr(_Inout_ struct _exception *except);
83 #endif
84
85 #ifndef _CRT_ATOF_DEFINED
86 #define _CRT_ATOF_DEFINED
87
88 _Check_return_
89 _CRTIMP
90 double
91 __cdecl
92 atof(
93 _In_z_ const char *str);
94
95 _Check_return_
96 _CRTIMP
97 double
98 __cdecl
99 _atof_l(
100 _In_z_ const char *str,
101 _In_opt_ _locale_t locale);
102
103 #endif /* _CRT_ATOF_DEFINED */
104
105 #ifndef _SIGN_DEFINED
106 #define _SIGN_DEFINED
107 _Check_return_ _CRTIMP double __cdecl _copysign(_In_ double x, _In_ double sgn);
108 _Check_return_ _CRTIMP double __cdecl _chgsign(_In_ double x);
109 #endif
110
111 _CRTIMP double __cdecl _cabs(_In_ struct _complex a);
112 _CRTIMP double __cdecl ceil(_In_ double x);
113 _CRTIMP double __cdecl floor(_In_ double x);
114 _CRTIMP double __cdecl frexp(_In_ double x, _Out_ int *y);
115 _CRTIMP double __cdecl _hypot(_In_ double x, _In_ double y);
116 _CRTIMP double __cdecl _j0(_In_ double x);
117 _CRTIMP double __cdecl _j1(_In_ double x);
118 _CRTIMP double __cdecl _jn(_In_ int x, _In_ double y);
119 _CRTIMP double __cdecl ldexp(_In_ double x, _In_ int y);
120 _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y);
121 _CRTIMP double __cdecl _y0(_In_ double x);
122 _CRTIMP double __cdecl _y1(_In_ double x);
123 _CRTIMP double __cdecl _yn(_In_ int x, _In_ double y);
124 _CRTIMP float __cdecl _hypotf(_In_ float x, _In_ float y);
125
126 #if defined(__i386__) || defined(_M_IX86)
127 _CRTIMP int __cdecl _set_SSE2_enable(_In_ int flag);
128 #endif
129
130 #if defined(__x86_64) || defined(_M_AMD64)
131 _CRTIMP float __cdecl _copysignf(_In_ float x, _In_ float sgn);
132 _CRTIMP float __cdecl _chgsignf(_In_ float x);
133 _CRTIMP float __cdecl _logbf(_In_ float x);
134 _CRTIMP float __cdecl _nextafterf(_In_ float x, _In_ float y);
135 _CRTIMP int __cdecl _finitef(_In_ float x);
136 _CRTIMP int __cdecl _isnanf(_In_ float x);
137 _CRTIMP int __cdecl _fpclassf(_In_ float x);
138 #endif
139
140 #if defined(__ia64__) || defined (_M_IA64)
141 _CRTIMP float __cdecl fabsf(_In_ float x);
142 _CRTIMP float __cdecl ldexpf(_In_ float x, _In_ int y);
143 _CRTIMP long double __cdecl tanl(_In_ long double x);
144 #else
145 __CRT_INLINE float __cdecl fabsf(_In_ float x) { return ((float)fabs((double)x)); }
146 __CRT_INLINE float __cdecl ldexpf(_In_ float x, _In_ int expn) { return (float)ldexp(x, expn); }
147 __CRT_INLINE long double tanl(_In_ long double x) { return (tan((double)x)); }
148 #endif
149
150 #if (_WIN32_WINNT >= 0x600) && \
151 (defined(__x86_64) || defined(_M_AMD64) || \
152 defined (__ia64__) || defined (_M_IA64))
153
154 _CRTIMP float __cdecl acosf(_In_ float x);
155 _CRTIMP float __cdecl asinf(_In_ float x);
156 _CRTIMP float __cdecl atanf(_In_ float x);
157 _CRTIMP float __cdecl atan2f(_In_ float x, _In_ float y);
158 _CRTIMP float __cdecl ceilf(_In_ float x);
159 _CRTIMP float __cdecl cosf(_In_ float x);
160 _CRTIMP float __cdecl coshf(_In_ float x);
161 _CRTIMP float __cdecl expf(_In_ float x);
162 _CRTIMP float __cdecl floorf(_In_ float x);
163 _CRTIMP float __cdecl fmodf(_In_ float x, _In_ float y);
164 _CRTIMP float __cdecl logf(_In_ float x);
165 _CRTIMP float __cdecl log10f(_In_ float x);
166 _CRTIMP float __cdecl modff(_In_ float x, _Out_ float *y);
167 _CRTIMP float __cdecl powf(_In_ float b, _In_ float e);
168 _CRTIMP float __cdecl sinf(_In_ float x);
169 _CRTIMP float __cdecl sinhf(_In_ float x);
170 _CRTIMP float __cdecl sqrtf(_In_ float x);
171 _CRTIMP float __cdecl tanf(_In_ float x);
172 _CRTIMP float __cdecl tanhf(_In_ float x);
173
174 #else
175
176 __CRT_INLINE float acosf(_In_ float x) { return ((float)acos((double)x)); }
177 __CRT_INLINE float asinf(_In_ float x) { return ((float)asin((double)x)); }
178 __CRT_INLINE float atanf(_In_ float x) { return ((float)atan((double)x)); }
179 __CRT_INLINE float atan2f(_In_ float x, _In_ float y) { return ((float)atan2((double)x,(double)y)); }
180 __CRT_INLINE float ceilf(_In_ float x) { return ((float)ceil((double)x)); }
181 __CRT_INLINE float cosf(_In_ float x) { return ((float)cos((double)x)); }
182 __CRT_INLINE float coshf(_In_ float x) { return ((float)cosh((double)x)); }
183 __CRT_INLINE float expf(_In_ float x) { return ((float)exp((double)x)); }
184 __CRT_INLINE float floorf(_In_ float x) { return ((float)floor((double)x)); }
185 __CRT_INLINE float fmodf(_In_ float x, _In_ float y) { return ((float)fmod((double)x,(double)y)); }
186 __CRT_INLINE float logf(_In_ float x) { return ((float)log((double)x)); }
187 __CRT_INLINE float log10f(_In_ float x) { return ((float)log10((double)x)); }
188 __CRT_INLINE float modff(_In_ float x, _Out_ float *y) {
189 double _Di,_Df = modf((double)x,&_Di);
190 *y = (float)_Di;
191 return ((float)_Df);
192 }
193 __CRT_INLINE float powf(_In_ float x, _In_ float y) { return ((float)pow((double)x,(double)y)); }
194 __CRT_INLINE float sinf(_In_ float x) { return ((float)sin((double)x)); }
195 __CRT_INLINE float sinhf(_In_ float x) { return ((float)sinh((double)x)); }
196 __CRT_INLINE float sqrtf(_In_ float x) { return ((float)sqrt((double)x)); }
197 __CRT_INLINE float tanf(_In_ float x) { return ((float)tan((double)x)); }
198 __CRT_INLINE float tanhf(_In_ float x) { return ((float)tanh((double)x)); }
199
200 #endif
201
202 __CRT_INLINE long double acosl(_In_ long double x) { return (acos((double)x)); }
203 __CRT_INLINE long double asinl(_In_ long double x) { return (asin((double)x)); }
204 __CRT_INLINE long double atanl(_In_ long double x) { return (atan((double)x)); }
205 __CRT_INLINE long double atan2l(_In_ long double y, _In_ long double x) { return (atan2((double)y, (double)x)); }
206 __CRT_INLINE long double ceill(_In_ long double x) { return (ceil((double)x)); }
207 __CRT_INLINE long double cosl(_In_ long double x) { return (cos((double)x)); }
208 __CRT_INLINE long double coshl(_In_ long double x) { return (cosh((double)x)); }
209 __CRT_INLINE long double expl(_In_ long double x) { return (exp((double)x)); }
210 __CRT_INLINE long double floorl(_In_ long double x) { return (floor((double)x)); }
211 __CRT_INLINE long double fmodl(_In_ long double x, _In_ long double y) { return (fmod((double)x, (double)y)); }
212 __CRT_INLINE long double frexpl(_In_ long double x, _Out_ int *y) { return (frexp((double)x, y)); }
213 __CRT_INLINE long double logl(_In_ long double x) { return (log((double)x)); }
214 __CRT_INLINE long double log10l(_In_ long double x) { return (log10((double)x)); }
215 __CRT_INLINE long double powl(_In_ long double x, _In_ long double y) { return (pow((double)x, (double)y)); }
216 __CRT_INLINE long double sinl(_In_ long double x) { return (sin((double)x)); }
217 __CRT_INLINE long double sinhl(_In_ long double x) { return (sinh((double)x)); }
218 __CRT_INLINE long double sqrtl(_In_ long double x) { return (sqrt((double)x)); }
219 __CRT_INLINE long double tanhl(_In_ long double x) {return (tanh((double)x)); }
220 __CRT_INLINE long double __cdecl fabsl(_In_ long double x) { return fabs((double)x); }
221 __CRT_INLINE long double _chgsignl(_In_ long double _Number) { return _chgsign((double)(_Number)); }
222 __CRT_INLINE long double _copysignl(_In_ long double _Number, _In_ long double _Sign) { return _copysign((double)(_Number),(double)(_Sign)); }
223 __CRT_INLINE long double _hypotl(_In_ long double x, _In_ long double y) { return _hypot((double)(x),(double)(y)); }
224 __CRT_INLINE float frexpf(_In_ float x, _Out_ int *y) { return ((float)frexp((double)x,y)); }
225 __CRT_INLINE long double ldexpl(_In_ long double x, _In_ int y) { return ldexp((double)x, y); }
226 __CRT_INLINE long double modfl(_In_ long double x, _Out_ long double *y) {
227 double _Di,_Df = modf((double)x,&_Di);
228 *y = (long double)_Di;
229 return (_Df);
230 }
231
232 #ifndef NO_OLDNAMES
233
234 #define DOMAIN _DOMAIN
235 #define SING _SING
236 #define OVERFLOW _OVERFLOW
237 #define UNDERFLOW _UNDERFLOW
238 #define TLOSS _TLOSS
239 #define PLOSS _PLOSS
240 #define matherr _matherr
241 #define HUGE _HUGE
242 // _CRTIMP double __cdecl cabs(struct _complex x);
243 #define cabs _cabs
244
245 _CRTIMP double __cdecl hypot(_In_ double x, _In_ double y);
246 _CRTIMP double __cdecl j0(_In_ double x);
247 _CRTIMP double __cdecl j1(_In_ double x);
248 _CRTIMP double __cdecl jn(_In_ int x, _In_ double y);
249 _CRTIMP double __cdecl y0(_In_ double x);
250 _CRTIMP double __cdecl y1(_In_ double x);
251 _CRTIMP double __cdecl yn(_In_ int x, _In_ double y);
252 __CRT_INLINE float __cdecl hypotf(_In_ float x, _In_ float y) { return (float) hypot(x, y); }
253
254 #endif /* NO_OLDNAMES */
255
256 #ifdef __cplusplus
257 }
258 extern "C++" {
259 template<class _Ty> inline _Ty _Pow_int(_Ty x,int y) {
260 unsigned int _N;
261 if(y >= 0) _N = (unsigned int)y;
262 else _N = (unsigned int)(-y);
263 for(_Ty _Z = _Ty(1);;x *= x) {
264 if((_N & 1)!=0) _Z *= x;
265 if((_N >>= 1)==0) return (y < 0 ? _Ty(1) / _Z : _Z);
266 }
267 }
268 }
269 #endif
270
271 #pragma pack(pop)
272
273 #endif /* !_INC_MATH */
274
275 #if defined(_USE_MATH_DEFINES) && !defined(_MATH_DEFINES_DEFINED)
276 #define _MATH_DEFINES_DEFINED
277
278 #define M_E 2.71828182845904523536
279 #define M_LOG2E 1.44269504088896340736
280 #define M_LOG10E 0.434294481903251827651
281 #define M_LN2 0.693147180559945309417
282 #define M_LN10 2.30258509299404568402
283 #define M_PI 3.14159265358979323846
284 #define M_PI_2 1.57079632679489661923
285 #define M_PI_4 0.785398163397448309616
286 #define M_1_PI 0.318309886183790671538
287 #define M_2_PI 0.636619772367581343076
288 #define M_2_SQRTPI 1.12837916709551257390
289 #define M_SQRT2 1.41421356237309504880
290 #define M_SQRT1_2 0.707106781186547524401
291
292 #endif /* _USE_MATH_DEFINES */