uiautomationcore/tests: Release interfaces returned from get_HostRawElementProvider.
[wine.git] / include / msvcrt / math.h
blobdba2b07be3738d7d9a765245c4d7c02927996eb0
1 /*
2 * Math functions.
4 * Derived from the mingw header written by Colin Peters.
5 * Modified for Wine use by Hans Leidekker.
6 * This file is in the public domain.
7 */
9 #ifndef __WINE_MATH_H
10 #define __WINE_MATH_H
12 #include <corecrt.h>
14 #include <pshpack8.h>
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
20 #define _DOMAIN 1 /* domain error in argument */
21 #define _SING 2 /* singularity */
22 #define _OVERFLOW 3 /* range overflow */
23 #define _UNDERFLOW 4 /* range underflow */
24 #define _TLOSS 5 /* total loss of precision */
25 #define _PLOSS 6 /* partial loss of precision */
27 #ifndef _EXCEPTION_DEFINED
28 #define _EXCEPTION_DEFINED
29 struct _exception
31 int type;
32 char *name;
33 double arg1;
34 double arg2;
35 double retval;
37 #endif /* _EXCEPTION_DEFINED */
39 #ifndef _COMPLEX_DEFINED
40 #define _COMPLEX_DEFINED
41 struct _complex
43 double x; /* Real part */
44 double y; /* Imaginary part */
46 #endif /* _COMPLEX_DEFINED */
48 _ACRTIMP double __cdecl sin(double);
49 _ACRTIMP double __cdecl cos(double);
50 _ACRTIMP double __cdecl tan(double);
51 _ACRTIMP double __cdecl sinh(double);
52 _ACRTIMP double __cdecl cosh(double);
53 _ACRTIMP double __cdecl tanh(double);
54 _ACRTIMP double __cdecl asin(double);
55 _ACRTIMP double __cdecl acos(double);
56 _ACRTIMP double __cdecl atan(double);
57 _ACRTIMP double __cdecl atan2(double, double);
58 _ACRTIMP double __cdecl asinh(double);
59 _ACRTIMP double __cdecl acosh(double);
60 _ACRTIMP double __cdecl atanh(double);
61 _ACRTIMP double __cdecl exp(double);
62 _ACRTIMP double __cdecl log(double);
63 _ACRTIMP double __cdecl log10(double);
64 _ACRTIMP double __cdecl pow(double, double);
65 _ACRTIMP double __cdecl sqrt(double);
66 _ACRTIMP double __cdecl ceil(double);
67 _ACRTIMP double __cdecl floor(double);
68 _ACRTIMP double __cdecl fabs(double);
69 _ACRTIMP double __cdecl ldexp(double, int);
70 _ACRTIMP double __cdecl frexp(double, int*);
71 _ACRTIMP double __cdecl modf(double, double*);
72 _ACRTIMP double __cdecl fdim(double, double);
73 _ACRTIMP double __cdecl fmod(double, double);
74 _ACRTIMP double __cdecl fmin(double, double);
75 _ACRTIMP double __cdecl fmax(double, double);
76 _ACRTIMP double __cdecl erf(double);
77 _ACRTIMP double __cdecl remainder(double, double);
78 _ACRTIMP double __cdecl remquo(double, double, int*);
79 _ACRTIMP float __cdecl remquof(float, float, int*);
80 _ACRTIMP double __cdecl lgamma(double);
81 _ACRTIMP double __cdecl tgamma(double);
83 _ACRTIMP double __cdecl _hypot(double, double);
84 _ACRTIMP double __cdecl _j0(double);
85 _ACRTIMP double __cdecl _j1(double);
86 _ACRTIMP double __cdecl _jn(int, double);
87 _ACRTIMP double __cdecl _y0(double);
88 _ACRTIMP double __cdecl _y1(double);
89 _ACRTIMP double __cdecl _yn(int, double);
91 _ACRTIMP double __cdecl cbrt(double);
92 _ACRTIMP double __cdecl exp2(double);
93 _ACRTIMP double __cdecl expm1(double);
94 _ACRTIMP double __cdecl log1p(double);
95 _ACRTIMP double __cdecl log2(double);
96 _ACRTIMP double __cdecl logb(double);
97 _ACRTIMP double __cdecl rint(double);
98 _ACRTIMP double __cdecl round(double);
99 _ACRTIMP double __cdecl trunc(double);
101 _ACRTIMP float __cdecl cbrtf(float);
102 _ACRTIMP float __cdecl exp2f(float);
103 _ACRTIMP float __cdecl expm1f(float);
104 _ACRTIMP float __cdecl log1pf(float);
105 _ACRTIMP float __cdecl log2f(float);
106 _ACRTIMP float __cdecl logbf(float);
107 _ACRTIMP float __cdecl rintf(float);
108 _ACRTIMP float __cdecl roundf(float);
109 _ACRTIMP float __cdecl truncf(float);
111 _ACRTIMP int __cdecl ilogb(double);
112 _ACRTIMP int __cdecl ilogbf(float);
114 _ACRTIMP __int64 __cdecl llrint(double);
115 _ACRTIMP __int64 __cdecl llrintf(float);
116 _ACRTIMP __int64 __cdecl llround(double);
117 _ACRTIMP __int64 __cdecl llroundf(float);
118 _ACRTIMP __msvcrt_long __cdecl lrint(double);
119 _ACRTIMP __msvcrt_long __cdecl lrintf(float);
120 _ACRTIMP __msvcrt_long __cdecl lround(double);
121 _ACRTIMP __msvcrt_long __cdecl lroundf(float);
123 _ACRTIMP double __cdecl scalbn(double,int);
124 _ACRTIMP float __cdecl scalbnf(float,int);
125 _ACRTIMP double __cdecl scalbln(double,__msvcrt_long);
126 _ACRTIMP float __cdecl scalblnf(float,__msvcrt_long);
128 _ACRTIMP double __cdecl _copysign (double, double);
129 _ACRTIMP double __cdecl _chgsign (double);
130 _ACRTIMP double __cdecl _scalb(double, __msvcrt_long);
131 _ACRTIMP double __cdecl _logb(double);
132 _ACRTIMP double __cdecl _nextafter(double, double);
133 _ACRTIMP int __cdecl _finite(double);
134 _ACRTIMP int __cdecl _isnan(double);
135 _ACRTIMP int __cdecl _fpclass(double);
137 _ACRTIMP double __cdecl nextafter(double, double);
139 #ifndef __i386__
141 _ACRTIMP float __cdecl sinf(float);
142 _ACRTIMP float __cdecl cosf(float);
143 _ACRTIMP float __cdecl tanf(float);
144 _ACRTIMP float __cdecl sinhf(float);
145 _ACRTIMP float __cdecl coshf(float);
146 _ACRTIMP float __cdecl tanhf(float);
147 _ACRTIMP float __cdecl asinf(float);
148 _ACRTIMP float __cdecl acosf(float);
149 _ACRTIMP float __cdecl atanf(float);
150 _ACRTIMP float __cdecl atan2f(float, float);
151 _ACRTIMP float __cdecl atanhf(float);
152 _ACRTIMP float __cdecl expf(float);
153 _ACRTIMP float __cdecl logf(float);
154 _ACRTIMP float __cdecl log10f(float);
155 _ACRTIMP float __cdecl powf(float, float);
156 _ACRTIMP float __cdecl sqrtf(float);
157 _ACRTIMP float __cdecl ceilf(float);
158 _ACRTIMP float __cdecl floorf(float);
159 _ACRTIMP float __cdecl frexpf(float, int*);
160 _ACRTIMP float __cdecl modff(float, float*);
161 _ACRTIMP float __cdecl fmodf(float, float);
163 _ACRTIMP int __cdecl _finitef(float);
164 _ACRTIMP int __cdecl _isnanf(float);
165 _ACRTIMP int __cdecl _fpclassf(float);
167 #else
169 static inline float sinf(float x) { return sin(x); }
170 static inline float cosf(float x) { return cos(x); }
171 static inline float tanf(float x) { return tan(x); }
172 static inline float sinhf(float x) { return sinh(x); }
173 static inline float coshf(float x) { return cosh(x); }
174 static inline float tanhf(float x) { return tanh(x); }
175 static inline float asinf(float x) { return asin(x); }
176 static inline float acosf(float x) { return acos(x); }
177 static inline float atanf(float x) { return atan(x); }
178 static inline float atan2f(float x, float y) { return atan2(x, y); }
179 static inline float expf(float x) { return exp(x); }
180 static inline float logf(float x) { return log(x); }
181 static inline float log10f(float x) { return log10(x); }
182 static inline float powf(float x, float y) { return pow(x, y); }
183 static inline float sqrtf(float x) { return sqrt(x); }
184 static inline float ceilf(float x) { return ceil(x); }
185 static inline float floorf(float x) { return floor(x); }
186 static inline float frexpf(float x, int *y) { return frexp(x, y); }
187 static inline float modff(float x, float *y) { double yd, ret = modf(x, &yd); *y = yd; return ret; }
188 static inline float fmodf(float x, float y) { return fmod(x, y); }
190 static inline int _finitef(float x) { return _finite(x); }
191 static inline int _isnanf(float x) { return _isnan(x); }
193 static inline int _fpclassf(float x)
195 unsigned int ix = *(int*)&x;
196 double d = x;
198 /* construct denormal double */
199 if (!(ix >> 23 & 0xff) && (ix << 1))
201 unsigned __int64 id = (((unsigned __int64)ix >> 31) << 63) | 1;
202 d = *(double*)&id;
204 return _fpclass(d);
207 #endif
209 #if !defined(__i386__) && !defined(__x86_64__) && (_MSVCR_VER == 0 || _MSVCR_VER >= 110)
210 _ACRTIMP float __cdecl fabsf(float);
211 #else
212 static inline float fabsf(float x) { return fabs(x); }
213 #endif
215 #if !defined(__i386__) || _MSVCR_VER>=120
217 _ACRTIMP float __cdecl _chgsignf(float);
218 _ACRTIMP float __cdecl _copysignf(float, float);
219 _ACRTIMP float __cdecl _logbf(float);
220 _ACRTIMP float __cdecl acoshf(float);
221 _ACRTIMP float __cdecl asinhf(float);
222 _ACRTIMP float __cdecl atanhf(float);
223 _ACRTIMP float __cdecl erff(float);
224 _ACRTIMP float __cdecl fdimf(float, float);
225 _ACRTIMP float __cdecl fmaxf(float, float);
226 _ACRTIMP float __cdecl fminf(float, float);
227 _ACRTIMP float __cdecl lgammaf(float);
228 _ACRTIMP float __cdecl nextafterf(float, float);
229 _ACRTIMP float __cdecl remainderf(float, float);
230 _ACRTIMP float __cdecl tgammaf(float);
232 #else
234 static inline float _chgsignf(float x) { return _chgsign(x); }
235 static inline float _copysignf(float x, float y) { return _copysign(x, y); }
236 static inline float _logbf(float x) { return _logb(x); }
238 #endif
240 static inline float ldexpf(float x, int y) { return ldexp(x, y); }
242 #ifdef _UCRT
243 _ACRTIMP double __cdecl copysign(double, double);
244 _ACRTIMP float __cdecl copysignf(float, float);
245 #else
246 #define copysign(x,y) _copysign(x,y)
247 #define copysignf(x,y) _copysignf(x,y)
248 #endif
250 _ACRTIMP double __cdecl nearbyint(double);
251 _ACRTIMP float __cdecl nearbyintf(float);
252 _ACRTIMP float __cdecl _hypotf(float, float);
253 _ACRTIMP int __cdecl _matherr(struct _exception*);
254 _ACRTIMP double __cdecl _cabs(struct _complex);
256 #if (defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))) || defined(__clang__)
257 # define INFINITY __builtin_inff()
258 # define NAN __builtin_nanf("")
259 # define HUGE_VAL __builtin_huge_val()
260 #else
261 static const union {
262 unsigned int __i;
263 float __f;
264 } __inff = { 0x7f800000 }, __nanf = { 0x7fc00000 };
265 # define INFINITY (__inff.__f)
266 # define NAN (__nanf.__f)
267 # define HUGE_VAL ((double)INFINITY)
268 #endif
270 #define FP_INFINITE 1
271 #define FP_NAN 2
272 #define FP_NORMAL -1
273 #define FP_SUBNORMAL -2
274 #define FP_ZERO 0
276 #define _C2 1
277 #define FP_ILOGB0 (-0x7fffffff - _C2)
278 #define FP_ILOGBNAN 0x7fffffff
280 #if _MSVCR_VER >= 120
282 _ACRTIMP short __cdecl _dclass(double);
283 _ACRTIMP short __cdecl _fdclass(float);
284 _ACRTIMP int __cdecl _dsign(double);
285 _ACRTIMP int __cdecl _fdsign(float);
287 #define fpclassify(x) (sizeof(x) == sizeof(float) ? _fdclass(x) : _dclass(x))
288 #define signbit(x) (sizeof(x) == sizeof(float) ? _fdsign(x) : _dsign(x))
289 #define isinf(x) (fpclassify(x) == FP_INFINITE)
290 #define isnan(x) (fpclassify(x) == FP_NAN)
291 #define isnormal(x) (fpclassify(x) == FP_NORMAL)
292 #define isfinite(x) (fpclassify(x) <= 0)
294 #else
296 static inline int __isnanf(float x)
298 union { float x; unsigned int i; } u = { x };
299 return (u.i & 0x7fffffff) > 0x7f800000;
301 static inline int __isnan(double x)
303 union { double x; unsigned __int64 i; } u = { x };
304 return (u.i & ~0ull >> 1) > 0x7ffull << 52;
306 static inline int __isinff(float x)
308 union { float x; unsigned int i; } u = { x };
309 return (u.i & 0x7fffffff) == 0x7f800000;
311 static inline int __isinf(double x)
313 union { double x; unsigned __int64 i; } u = { x };
314 return (u.i & ~0ull >> 1) == 0x7ffull << 52;
316 static inline int __isnormalf(float x)
318 union { float x; unsigned int i; } u = { x };
319 return ((u.i + 0x00800000) & 0x7fffffff) >= 0x01000000;
321 static inline int __isnormal(double x)
323 union { double x; unsigned __int64 i; } u = { x };
324 return ((u.i + (1ull << 52)) & ~0ull >> 1) >= 1ull << 53;
326 static inline int __signbitf(float x)
328 union { float x; unsigned int i; } u = { x };
329 return (int)(u.i >> 31);
331 static inline int __signbit(double x)
333 union { double x; unsigned __int64 i; } u = { x };
334 return (int)(u.i >> 63);
337 #define isinf(x) (sizeof(x) == sizeof(float) ? __isinff(x) : __isinf(x))
338 #define isnan(x) (sizeof(x) == sizeof(float) ? __isnanf(x) : __isnan(x))
339 #define isnormal(x) (sizeof(x) == sizeof(float) ? __isnormalf(x) : __isnormal(x))
340 #define signbit(x) (sizeof(x) == sizeof(float) ? __signbitf(x) : __signbit(x))
341 #define isfinite(x) (!isinf(x) && !isnan(x))
343 #endif
345 #ifdef __cplusplus
347 #endif
349 #include <poppack.h>
351 #if !defined(__STRICT_ANSI__) || defined(_POSIX_C_SOURCE) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_USE_MATH_DEFINES)
352 #ifndef _MATH_DEFINES_DEFINED
353 #define _MATH_DEFINES_DEFINED
354 #define M_E 2.71828182845904523536
355 #define M_LOG2E 1.44269504088896340736
356 #define M_LOG10E 0.434294481903251827651
357 #define M_LN2 0.693147180559945309417
358 #define M_LN10 2.30258509299404568402
359 #define M_PI 3.14159265358979323846
360 #define M_PI_2 1.57079632679489661923
361 #define M_PI_4 0.785398163397448309616
362 #define M_1_PI 0.318309886183790671538
363 #define M_2_PI 0.636619772367581343076
364 #define M_2_SQRTPI 1.12837916709551257390
365 #define M_SQRT2 1.41421356237309504880
366 #define M_SQRT1_2 0.707106781186547524401
367 #endif /* !_MATH_DEFINES_DEFINED */
368 #endif /* _USE_MATH_DEFINES */
370 static inline double hypot( double x, double y ) { return _hypot( x, y ); }
371 static inline double j0( double x ) { return _j0( x ); }
372 static inline double j1( double x ) { return _j1( x ); }
373 static inline double jn( int n, double x ) { return _jn( n, x ); }
374 static inline double y0( double x ) { return _y0( x ); }
375 static inline double y1( double x ) { return _y1( x ); }
376 static inline double yn( int n, double x ) { return _yn( n, x ); }
378 static inline float hypotf( float x, float y ) { return _hypotf( x, y ); }
380 #endif /* __WINE_MATH_H */