msvcrt: Don't export fabsf on x86_64.
[wine.git] / include / msvcrt / math.h
blob43e82fc3bea2d49bad2e3dae8e9cdbb6052d9e71
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 atanhf(float);
129 _ACRTIMP float __cdecl expf(float);
130 _ACRTIMP float __cdecl logf(float);
131 _ACRTIMP float __cdecl log10f(float);
132 _ACRTIMP float __cdecl powf(float, float);
133 _ACRTIMP float __cdecl sqrtf(float);
134 _ACRTIMP float __cdecl ceilf(float);
135 _ACRTIMP float __cdecl floorf(float);
136 _ACRTIMP float __cdecl frexpf(float, int*);
137 _ACRTIMP float __cdecl modff(float, float*);
138 _ACRTIMP float __cdecl fmodf(float, float);
140 _ACRTIMP int __cdecl _finitef(float);
141 _ACRTIMP int __cdecl _isnanf(float);
142 _ACRTIMP int __cdecl _fpclassf(float);
144 #else
146 static inline float sinf(float x) { return sin(x); }
147 static inline float cosf(float x) { return cos(x); }
148 static inline float tanf(float x) { return tan(x); }
149 static inline float sinhf(float x) { return sinh(x); }
150 static inline float coshf(float x) { return cosh(x); }
151 static inline float tanhf(float x) { return tanh(x); }
152 static inline float asinf(float x) { return asin(x); }
153 static inline float acosf(float x) { return acos(x); }
154 static inline float atanf(float x) { return atan(x); }
155 static inline float atan2f(float x, float y) { return atan2(x, y); }
156 static inline float expf(float x) { return exp(x); }
157 static inline float logf(float x) { return log(x); }
158 static inline float log10f(float x) { return log10(x); }
159 static inline float powf(float x, float y) { return pow(x, y); }
160 static inline float sqrtf(float x) { return sqrt(x); }
161 static inline float ceilf(float x) { return ceil(x); }
162 static inline float floorf(float x) { return floor(x); }
163 static inline float frexpf(float x, int *y) { return frexp(x, y); }
164 static inline float modff(float x, float *y) { double yd, ret = modf(x, &yd); *y = yd; return ret; }
165 static inline float fmodf(float x, float y) { return fmod(x, y); }
167 static inline int _finitef(float x) { return _finite(x); }
168 static inline int _isnanf(float x) { return _isnan(x); }
169 static inline int _fpclassf(float x) { return _fpclass(x); }
171 #endif
173 #if !defined(__i386__) && !defined(__x86_64__) && (_MSVCR_VER == 0 || _MSVCR_VER >= 110)
174 _ACRTIMP float __cdecl fabsf(float);
175 #else
176 static inline float fabsf(float x) { return fabs(x); }
177 #endif
179 #if !defined(__i386__) || _MSVCR_VER>=120
181 _ACRTIMP float __cdecl _chgsignf(float);
182 _ACRTIMP float __cdecl _copysignf(float, float);
183 _ACRTIMP float __cdecl _logbf(float);
184 _ACRTIMP float __cdecl acoshf(float);
185 _ACRTIMP float __cdecl asinhf(float);
186 _ACRTIMP float __cdecl atanhf(float);
188 #else
190 static inline float _chgsignf(float x) { return _chgsign(x); }
191 static inline float _copysignf(float x, float y) { return _copysign(x, y); }
192 static inline float _logbf(float x) { return _logb(x); }
193 static inline float acoshf(float x) { return acosh(x); }
194 static inline float asinhf(float x) { return asinh(x); }
195 static inline float atanhf(float x) { return atanh(x); }
197 #endif
199 static inline float ldexpf(float x, int y) { return ldexp(x, y); }
201 #ifdef _UCRT
202 _ACRTIMP double __cdecl copysign(double, double);
203 _ACRTIMP float __cdecl copysignf(float, float);
204 #else
205 #define copysign(x,y) _copysign(x,y)
206 #define copysignf(x,y) _copysignf(x,y)
207 #endif
209 _ACRTIMP double __cdecl nearbyint(double);
210 _ACRTIMP float __cdecl nearbyintf(float);
211 _ACRTIMP float __cdecl _hypotf(float, float);
212 _ACRTIMP int __cdecl _matherr(struct _exception*);
213 _ACRTIMP double __cdecl _cabs(struct _complex);
215 #if (defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))) || defined(__clang__)
216 # define INFINITY __builtin_inff()
217 # define NAN __builtin_nanf("")
218 # define HUGE_VAL __builtin_huge_val()
219 #else
220 static const union {
221 unsigned int __i;
222 float __f;
223 } __inff = { 0x7f800000 }, __nanf = { 0x7fc00000 };
224 # define INFINITY (__inff.__f)
225 # define NAN (__nanf.__f)
226 # define HUGE_VAL ((double)INFINITY)
227 #endif
229 #define FP_INFINITE 1
230 #define FP_NAN 2
231 #define FP_NORMAL -1
232 #define FP_SUBNORMAL -2
233 #define FP_ZERO 0
235 #define _C2 1
236 #define FP_ILOGB0 (-0x7fffffff - _C2)
237 #define FP_ILOGBNAN 0x7fffffff
239 _ACRTIMP short __cdecl _dclass(double);
240 _ACRTIMP short __cdecl _fdclass(float);
241 _ACRTIMP int __cdecl _dsign(double);
242 _ACRTIMP int __cdecl _fdsign(float);
244 static inline int __isnanf(float x)
246 union { float x; unsigned int i; } u = { x };
247 return (u.i & 0x7fffffff) > 0x7f800000;
249 static inline int __isnan(double x)
251 union { double x; unsigned __int64 i; } u = { x };
252 return (u.i & ~0ull >> 1) > 0x7ffull << 52;
254 static inline int __isinff(float x)
256 union { float x; unsigned int i; } u = { x };
257 return (u.i & 0x7fffffff) == 0x7f800000;
259 static inline int __isinf(double x)
261 union { double x; unsigned __int64 i; } u = { x };
262 return (u.i & ~0ull >> 1) == 0x7ffull << 52;
264 static inline int __isnormalf(float x)
266 union { float x; unsigned int i; } u = { x };
267 return ((u.i + 0x00800000) & 0x7fffffff) >= 0x01000000;
269 static inline int __isnormal(double x)
271 union { double x; unsigned __int64 i; } u = { x };
272 return ((u.i + (1ull << 52)) & ~0ull >> 1) >= 1ull << 53;
274 static inline int __signbitf(float x)
276 union { float x; unsigned int i; } u = { x };
277 return (int)(u.i >> 31);
279 static inline int __signbit(double x)
281 union { double x; unsigned __int64 i; } u = { x };
282 return (int)(u.i >> 63);
285 #define isinf(x) (sizeof(x) == sizeof(float) ? __isinff(x) : __isinf(x))
286 #define isnan(x) (sizeof(x) == sizeof(float) ? __isnanf(x) : __isnan(x))
287 #define isnormal(x) (sizeof(x) == sizeof(float) ? __isnormalf(x) : __isnormal(x))
288 #define signbit(x) (sizeof(x) == sizeof(float) ? __signbitf(x) : __signbit(x))
289 #define isfinite(x) (!isinf(x) && !isnan(x))
291 #ifdef __cplusplus
293 #endif
295 #include <poppack.h>
297 #if !defined(__STRICT_ANSI__) || defined(_POSIX_C_SOURCE) || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_USE_MATH_DEFINES)
298 #ifndef _MATH_DEFINES_DEFINED
299 #define _MATH_DEFINES_DEFINED
300 #define M_E 2.71828182845904523536
301 #define M_LOG2E 1.44269504088896340736
302 #define M_LOG10E 0.434294481903251827651
303 #define M_LN2 0.693147180559945309417
304 #define M_LN10 2.30258509299404568402
305 #define M_PI 3.14159265358979323846
306 #define M_PI_2 1.57079632679489661923
307 #define M_PI_4 0.785398163397448309616
308 #define M_1_PI 0.318309886183790671538
309 #define M_2_PI 0.636619772367581343076
310 #define M_2_SQRTPI 1.12837916709551257390
311 #define M_SQRT2 1.41421356237309504880
312 #define M_SQRT1_2 0.707106781186547524401
313 #endif /* !_MATH_DEFINES_DEFINED */
314 #endif /* _USE_MATH_DEFINES */
316 static inline double hypot( double x, double y ) { return _hypot( x, y ); }
317 static inline double j0( double x ) { return _j0( x ); }
318 static inline double j1( double x ) { return _j1( x ); }
319 static inline double jn( int n, double x ) { return _jn( n, x ); }
320 static inline double y0( double x ) { return _y0( x ); }
321 static inline double y1( double x ) { return _y1( x ); }
322 static inline double yn( int n, double x ) { return _yn( n, x ); }
324 static inline float hypotf( float x, float y ) { return _hypotf( x, y ); }
326 #endif /* __WINE_MATH_H */