ntdll: Initialize server directory on macOS when sending Mach port.
[wine.git] / include / msvcrt / math.h
blob01c4a4b61b47fa40be34398a321668f22d2085ed
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 double __cdecl sin(double);
49 double __cdecl cos(double);
50 double __cdecl tan(double);
51 double __cdecl sinh(double);
52 double __cdecl cosh(double);
53 double __cdecl tanh(double);
54 double __cdecl asin(double);
55 double __cdecl acos(double);
56 double __cdecl atan(double);
57 double __cdecl atan2(double, double);
58 double __cdecl asinh(double);
59 double __cdecl acosh(double);
60 double __cdecl atanh(double);
61 double __cdecl exp(double);
62 double __cdecl log(double);
63 double __cdecl log10(double);
64 double __cdecl pow(double, double);
65 double __cdecl sqrt(double);
66 double __cdecl ceil(double);
67 double __cdecl floor(double);
68 double __cdecl fabs(double);
69 double __cdecl ldexp(double, int);
70 double __cdecl frexp(double, int*);
71 double __cdecl modf(double, double*);
72 double __cdecl fmod(double, double);
73 double __cdecl fmin(double, double);
74 double __cdecl fmax(double, double);
75 double __cdecl erf(double);
77 double __cdecl _hypot(double, double);
78 double __cdecl _j0(double);
79 double __cdecl _j1(double);
80 double __cdecl _jn(int, double);
81 double __cdecl _y0(double);
82 double __cdecl _y1(double);
83 double __cdecl _yn(int, double);
85 double __cdecl cbrt(double);
86 double __cdecl exp2(double);
87 double __cdecl log2(double);
88 double __cdecl rint(double);
89 double __cdecl round(double);
90 double __cdecl trunc(double);
92 float __cdecl cbrtf(float);
93 float __cdecl exp2f(float);
94 float __cdecl log2f(float);
95 float __cdecl rintf(float);
96 float __cdecl roundf(float);
97 float __cdecl truncf(float);
99 long __cdecl lrint(double);
100 long __cdecl lrintf(float);
101 long __cdecl lround(double);
102 long __cdecl lroundf(float);
104 double __cdecl _copysign (double, double);
105 double __cdecl _chgsign (double);
106 double __cdecl _scalb(double, __msvcrt_long);
107 double __cdecl _logb(double);
108 double __cdecl _nextafter(double, double);
109 int __cdecl _finite(double);
110 int __cdecl _isnan(double);
111 int __cdecl _fpclass(double);
113 #ifndef __i386__
115 float __cdecl sinf(float);
116 float __cdecl cosf(float);
117 float __cdecl tanf(float);
118 float __cdecl sinhf(float);
119 float __cdecl coshf(float);
120 float __cdecl tanhf(float);
121 float __cdecl asinf(float);
122 float __cdecl acosf(float);
123 float __cdecl atanf(float);
124 float __cdecl atan2f(float, float);
125 float __cdecl asinhf(float);
126 float __cdecl acoshf(float);
127 float __cdecl atanhf(float);
128 float __cdecl expf(float);
129 float __cdecl logf(float);
130 float __cdecl log10f(float);
131 float __cdecl powf(float, float);
132 float __cdecl sqrtf(float);
133 float __cdecl ceilf(float);
134 float __cdecl floorf(float);
135 float __cdecl fabsf(float);
136 float __cdecl frexpf(float, int*);
137 float __cdecl modff(float, float*);
138 float __cdecl fmodf(float, float);
140 float __cdecl _copysignf(float, float);
141 float __cdecl _chgsignf(float);
142 float __cdecl _logbf(float);
143 int __cdecl _finitef(float);
144 int __cdecl _isnanf(float);
145 int __cdecl _fpclassf(float);
147 #else
149 static inline float sinf(float x) { return sin(x); }
150 static inline float cosf(float x) { return cos(x); }
151 static inline float tanf(float x) { return tan(x); }
152 static inline float sinhf(float x) { return sinh(x); }
153 static inline float coshf(float x) { return cosh(x); }
154 static inline float tanhf(float x) { return tanh(x); }
155 static inline float asinf(float x) { return asin(x); }
156 static inline float acosf(float x) { return acos(x); }
157 static inline float atanf(float x) { return atan(x); }
158 static inline float atan2f(float x, float y) { return atan2(x, y); }
159 static inline float asinhf(float x) { return asinh(x); }
160 static inline float acoshf(float x) { return acosh(x); }
161 static inline float atanhf(float x) { return atanh(x); }
162 static inline float expf(float x) { return exp(x); }
163 static inline float logf(float x) { return log(x); }
164 static inline float log10f(float x) { return log10(x); }
165 static inline float powf(float x, float y) { return pow(x, y); }
166 static inline float sqrtf(float x) { return sqrt(x); }
167 static inline float ceilf(float x) { return ceil(x); }
168 static inline float floorf(float x) { return floor(x); }
169 static inline float fabsf(float x) { return fabs(x); }
170 static inline float frexpf(float x, int *y) { return frexp(x, y); }
171 static inline float modff(float x, float *y) { double yd, ret = modf(x, &yd); *y = yd; return ret; }
172 static inline float fmodf(float x, float y) { return fmod(x, y); }
174 static inline float _copysignf(float x, float y) { return _copysign(x, y); }
175 static inline float _chgsignf(float x) { return _chgsign(x); }
176 static inline float _logbf(float x) { return _logb(x); }
177 static inline int _finitef(float x) { return _finite(x); }
178 static inline int _isnanf(float x) { return _isnan(x); }
179 static inline int _fpclassf(float x) { return _fpclass(x); }
181 #endif
183 static inline float ldexpf(float x, int y) { return ldexp(x, y); }
185 #define copysign(x,y) _copysign(x,y)
186 #define copysignf(x,y) _copysignf(x,y)
188 double __cdecl nearbyint(double);
189 float __cdecl nearbyintf(float);
191 float __cdecl _hypotf(float, float);
193 int __cdecl _matherr(struct _exception*);
194 double __cdecl _cabs(struct _complex);
196 #ifndef HUGE_VAL
197 # if defined(__GNUC__) && (__GNUC__ >= 3)
198 # define HUGE_VAL (__extension__ 0x1.0p2047)
199 # else
200 static const union {
201 unsigned char __c[8];
202 double __d;
203 } __huge_val = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } };
204 # define HUGE_VAL (__huge_val.__d)
205 # endif
206 #endif
208 #if (defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))) || defined(__clang__)
209 # define INFINITY __builtin_inff()
210 # define NAN __builtin_nanf("")
211 #else
212 static const union {
213 unsigned int __i;
214 float __f;
215 } __inff = { 0x7f800000 }, __nanf = { 0x7fc00000 };
216 # define INFINITY (__inff.__f)
217 # define NAN (__nanf.__f)
218 #endif
220 #define FP_INFINITE 1
221 #define FP_NAN 2
222 #define FP_NORMAL -1
223 #define FP_SUBNORMAL -2
224 #define FP_ZERO 0
226 short __cdecl _dclass(double);
227 #define isfinite(x) (_finite(x))
228 #define isinf(x) (!(_finite(x) || _isnan(x)))
229 #define isnan(x) (_isnan(x))
230 #define isnormal(x) (!!(_fpclass((double)(x)) & (_FPCLASS_NN|_FPCLASS_PN)))
232 #ifdef __cplusplus
234 #endif
236 #include <poppack.h>
238 #if !defined(__STRICT_ANSI__) || defined(_POSIX_C_SOURCE) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_USE_MATH_DEFINES)
239 #ifndef _MATH_DEFINES_DEFINED
240 #define _MATH_DEFINES_DEFINED
241 #define M_E 2.71828182845904523536
242 #define M_LOG2E 1.44269504088896340736
243 #define M_LOG10E 0.434294481903251827651
244 #define M_LN2 0.693147180559945309417
245 #define M_LN10 2.30258509299404568402
246 #define M_PI 3.14159265358979323846
247 #define M_PI_2 1.57079632679489661923
248 #define M_PI_4 0.785398163397448309616
249 #define M_1_PI 0.318309886183790671538
250 #define M_2_PI 0.636619772367581343076
251 #define M_2_SQRTPI 1.12837916709551257390
252 #define M_SQRT2 1.41421356237309504880
253 #define M_SQRT1_2 0.707106781186547524401
254 #endif /* !_MATH_DEFINES_DEFINED */
255 #endif /* _USE_MATH_DEFINES */
257 static inline double hypot( double x, double y ) { return _hypot( x, y ); }
258 static inline double j0( double x ) { return _j0( x ); }
259 static inline double j1( double x ) { return _j1( x ); }
260 static inline double jn( int n, double x ) { return _jn( n, x ); }
261 static inline double y0( double x ) { return _y0( x ); }
262 static inline double y1( double x ) { return _y1( x ); }
263 static inline double yn( int n, double x ) { return _yn( n, x ); }
265 static inline float hypotf( float x, float y ) { return _hypotf( x, y ); }
267 #endif /* __WINE_MATH_H */