iphlpapi: Move the ICMP reply retrieval to a helper function.
[wine.git] / include / msvcrt / math.h
blobf344261a9f3307e498bbdfed2d83deb7aeebe5ef
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 fmod(double, double);
73 _ACRTIMP double __cdecl fmin(double, double);
74 _ACRTIMP double __cdecl fmax(double, double);
75 _ACRTIMP double __cdecl erf(double);
77 _ACRTIMP double __cdecl _hypot(double, double);
78 _ACRTIMP double __cdecl _j0(double);
79 _ACRTIMP double __cdecl _j1(double);
80 _ACRTIMP double __cdecl _jn(int, double);
81 _ACRTIMP double __cdecl _y0(double);
82 _ACRTIMP double __cdecl _y1(double);
83 _ACRTIMP double __cdecl _yn(int, double);
85 _ACRTIMP double __cdecl cbrt(double);
86 _ACRTIMP double __cdecl exp2(double);
87 _ACRTIMP double __cdecl log2(double);
88 _ACRTIMP double __cdecl rint(double);
89 _ACRTIMP double __cdecl round(double);
90 _ACRTIMP double __cdecl trunc(double);
92 _ACRTIMP float __cdecl cbrtf(float);
93 _ACRTIMP float __cdecl exp2f(float);
94 _ACRTIMP float __cdecl log2f(float);
95 _ACRTIMP float __cdecl rintf(float);
96 _ACRTIMP float __cdecl roundf(float);
97 _ACRTIMP float __cdecl truncf(float);
99 _ACRTIMP __msvcrt_long __cdecl lrint(double);
100 _ACRTIMP __msvcrt_long __cdecl lrintf(float);
101 _ACRTIMP __msvcrt_long __cdecl lround(double);
102 _ACRTIMP __msvcrt_long __cdecl lroundf(float);
104 _ACRTIMP double __cdecl scalbn(double,int);
105 _ACRTIMP float __cdecl scalbnf(float,int);
107 _ACRTIMP double __cdecl _copysign (double, double);
108 _ACRTIMP double __cdecl _chgsign (double);
109 _ACRTIMP double __cdecl _scalb(double, __msvcrt_long);
110 _ACRTIMP double __cdecl _logb(double);
111 _ACRTIMP double __cdecl _nextafter(double, double);
112 _ACRTIMP int __cdecl _finite(double);
113 _ACRTIMP int __cdecl _isnan(double);
114 _ACRTIMP int __cdecl _fpclass(double);
116 #ifndef __i386__
118 _ACRTIMP float __cdecl sinf(float);
119 _ACRTIMP float __cdecl cosf(float);
120 _ACRTIMP float __cdecl tanf(float);
121 _ACRTIMP float __cdecl sinhf(float);
122 _ACRTIMP float __cdecl coshf(float);
123 _ACRTIMP float __cdecl tanhf(float);
124 _ACRTIMP float __cdecl asinf(float);
125 _ACRTIMP float __cdecl acosf(float);
126 _ACRTIMP float __cdecl atanf(float);
127 _ACRTIMP float __cdecl atan2f(float, float);
128 _ACRTIMP float __cdecl asinhf(float);
129 _ACRTIMP float __cdecl acoshf(float);
130 _ACRTIMP float __cdecl atanhf(float);
131 _ACRTIMP float __cdecl expf(float);
132 _ACRTIMP float __cdecl logf(float);
133 _ACRTIMP float __cdecl log10f(float);
134 _ACRTIMP float __cdecl powf(float, float);
135 _ACRTIMP float __cdecl sqrtf(float);
136 _ACRTIMP float __cdecl ceilf(float);
137 _ACRTIMP float __cdecl floorf(float);
138 _ACRTIMP float __cdecl fabsf(float);
139 _ACRTIMP float __cdecl frexpf(float, int*);
140 _ACRTIMP float __cdecl modff(float, float*);
141 _ACRTIMP float __cdecl fmodf(float, float);
143 _ACRTIMP float __cdecl _copysignf(float, float);
144 _ACRTIMP float __cdecl _chgsignf(float);
145 _ACRTIMP float __cdecl _logbf(float);
146 _ACRTIMP int __cdecl _finitef(float);
147 _ACRTIMP int __cdecl _isnanf(float);
148 _ACRTIMP int __cdecl _fpclassf(float);
150 #else
152 static inline float sinf(float x) { return sin(x); }
153 static inline float cosf(float x) { return cos(x); }
154 static inline float tanf(float x) { return tan(x); }
155 static inline float sinhf(float x) { return sinh(x); }
156 static inline float coshf(float x) { return cosh(x); }
157 static inline float tanhf(float x) { return tanh(x); }
158 static inline float asinf(float x) { return asin(x); }
159 static inline float acosf(float x) { return acos(x); }
160 static inline float atanf(float x) { return atan(x); }
161 static inline float atan2f(float x, float y) { return atan2(x, y); }
162 static inline float asinhf(float x) { return asinh(x); }
163 static inline float acoshf(float x) { return acosh(x); }
164 static inline float atanhf(float x) { return atanh(x); }
165 static inline float expf(float x) { return exp(x); }
166 static inline float logf(float x) { return log(x); }
167 static inline float log10f(float x) { return log10(x); }
168 static inline float powf(float x, float y) { return pow(x, y); }
169 static inline float sqrtf(float x) { return sqrt(x); }
170 static inline float ceilf(float x) { return ceil(x); }
171 static inline float floorf(float x) { return floor(x); }
172 static inline float fabsf(float x) { return fabs(x); }
173 static inline float frexpf(float x, int *y) { return frexp(x, y); }
174 static inline float modff(float x, float *y) { double yd, ret = modf(x, &yd); *y = yd; return ret; }
175 static inline float fmodf(float x, float y) { return fmod(x, y); }
177 static inline float _copysignf(float x, float y) { return _copysign(x, y); }
178 static inline float _chgsignf(float x) { return _chgsign(x); }
179 static inline float _logbf(float x) { return _logb(x); }
180 static inline int _finitef(float x) { return _finite(x); }
181 static inline int _isnanf(float x) { return _isnan(x); }
182 static inline int _fpclassf(float x) { return _fpclass(x); }
184 #endif
186 static inline float ldexpf(float x, int y) { return ldexp(x, y); }
188 #ifdef _UCRT
189 _ACRTIMP double __cdecl copysign(double, double);
190 _ACRTIMP float __cdecl copysignf(float, float);
191 #else
192 #define copysign(x,y) _copysign(x,y)
193 #define copysignf(x,y) _copysignf(x,y)
194 #endif
196 _ACRTIMP double __cdecl nearbyint(double);
197 _ACRTIMP float __cdecl nearbyintf(float);
198 _ACRTIMP float __cdecl _hypotf(float, float);
199 _ACRTIMP int __cdecl _matherr(struct _exception*);
200 _ACRTIMP double __cdecl _cabs(struct _complex);
202 #if (defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))) || defined(__clang__)
203 # define INFINITY __builtin_inff()
204 # define NAN __builtin_nanf("")
205 # define HUGE_VAL __builtin_huge_val()
206 #else
207 static const union {
208 unsigned int __i;
209 float __f;
210 } __inff = { 0x7f800000 }, __nanf = { 0x7fc00000 };
211 # define INFINITY (__inff.__f)
212 # define NAN (__nanf.__f)
213 # define HUGE_VAL ((double)INFINITY)
214 #endif
216 #define FP_INFINITE 1
217 #define FP_NAN 2
218 #define FP_NORMAL -1
219 #define FP_SUBNORMAL -2
220 #define FP_ZERO 0
222 #define _C2 1
223 #define FP_ILOGB0 (-0x7fffffff - _C2)
224 #define FP_ILOGBNAN 0x7fffffff
226 _ACRTIMP short __cdecl _dclass(double);
227 _ACRTIMP short __cdecl _fdclass(float);
228 _ACRTIMP int __cdecl _dsign(double);
229 _ACRTIMP int __cdecl _fdsign(float);
231 static inline int __isnanf(float x)
233 union { float x; unsigned int i; } u = { x };
234 return (u.i & 0x7fffffff) > 0x7f800000;
236 static inline int __isnan(double x)
238 union { double x; unsigned __int64 i; } u = { x };
239 return (u.i & ~0ull >> 1) > 0x7ffull << 52;
241 static inline int __isinff(float x)
243 union { float x; unsigned int i; } u = { x };
244 return (u.i & 0x7fffffff) == 0x7f800000;
246 static inline int __isinf(double x)
248 union { double x; unsigned __int64 i; } u = { x };
249 return (u.i & ~0ull >> 1) == 0x7ffull << 52;
251 static inline int __isnormalf(float x)
253 union { float x; unsigned int i; } u = { x };
254 return ((u.i + 0x00800000) & 0x7fffffff) >= 0x01000000;
256 static inline int __isnormal(double x)
258 union { double x; unsigned __int64 i; } u = { x };
259 return ((u.i + (1ull << 52)) & ~0ull >> 1) >= 1ull << 53;
261 static inline int __signbitf(float x)
263 union { float x; unsigned int i; } u = { x };
264 return (int)(u.i >> 31);
266 static inline int __signbit(double x)
268 union { double x; unsigned __int64 i; } u = { x };
269 return (int)(u.i >> 63);
272 #define isinf(x) (sizeof(x) == sizeof(float) ? __isinff(x) : __isinf(x))
273 #define isnan(x) (sizeof(x) == sizeof(float) ? __isnanf(x) : __isnan(x))
274 #define isnormal(x) (sizeof(x) == sizeof(float) ? __isnormalf(x) : __isnormal(x))
275 #define signbit(x) (sizeof(x) == sizeof(float) ? __signbitf(x) : __signbit(x))
276 #define isfinite(x) (!isinf(x) && !isnan(x))
278 #ifdef __cplusplus
280 #endif
282 #include <poppack.h>
284 #if !defined(__STRICT_ANSI__) || defined(_POSIX_C_SOURCE) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_USE_MATH_DEFINES)
285 #ifndef _MATH_DEFINES_DEFINED
286 #define _MATH_DEFINES_DEFINED
287 #define M_E 2.71828182845904523536
288 #define M_LOG2E 1.44269504088896340736
289 #define M_LOG10E 0.434294481903251827651
290 #define M_LN2 0.693147180559945309417
291 #define M_LN10 2.30258509299404568402
292 #define M_PI 3.14159265358979323846
293 #define M_PI_2 1.57079632679489661923
294 #define M_PI_4 0.785398163397448309616
295 #define M_1_PI 0.318309886183790671538
296 #define M_2_PI 0.636619772367581343076
297 #define M_2_SQRTPI 1.12837916709551257390
298 #define M_SQRT2 1.41421356237309504880
299 #define M_SQRT1_2 0.707106781186547524401
300 #endif /* !_MATH_DEFINES_DEFINED */
301 #endif /* _USE_MATH_DEFINES */
303 static inline double hypot( double x, double y ) { return _hypot( x, y ); }
304 static inline double j0( double x ) { return _j0( x ); }
305 static inline double j1( double x ) { return _j1( x ); }
306 static inline double jn( int n, double x ) { return _jn( n, x ); }
307 static inline double y0( double x ) { return _y0( x ); }
308 static inline double y1( double x ) { return _y1( x ); }
309 static inline double yn( int n, double x ) { return _yn( n, x ); }
311 static inline float hypotf( float x, float y ) { return _hypotf( x, y ); }
313 #endif /* __WINE_MATH_H */