msvcrt: Import expm1f implementation from musl.
[wine.git] / dlls / msvcrt / unixlib.c
blobc0c3a2b16360afa8add1d998d6981dc56db11bd8
1 /*
2 * MSVCRT Unix interface
4 * Copyright 2020 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #if 0
22 #pragma makedep unix
23 #endif
25 #include "config.h"
26 #include "wine/port.h"
28 #include <stdio.h>
29 #include <stdarg.h>
30 #define __USE_ISOC9X 1
31 #define __USE_ISOC99 1
32 #include <math.h>
33 #ifdef HAVE_IEEEFP_H
34 #include <ieeefp.h>
35 #endif
37 #include "ntstatus.h"
38 #define WIN32_NO_STATUS
39 #include "winternl.h"
40 #include "unixlib.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
45 /*********************************************************************
46 * cosh
48 static double CDECL unix_cosh( double x )
50 return cosh( x );
53 /*********************************************************************
54 * coshf
56 static float CDECL unix_coshf( float x )
58 return coshf( x );
61 /*********************************************************************
62 * exp
64 static double CDECL unix_exp( double x )
66 return exp( x );
69 /*********************************************************************
70 * expf
72 static float CDECL unix_expf( float x )
74 return expf( x );
77 /*********************************************************************
78 * exp2
80 static double CDECL unix_exp2( double x )
82 #ifdef HAVE_EXP2
83 return exp2(x);
84 #else
85 return pow(2, x);
86 #endif
89 /*********************************************************************
90 * exp2f
92 static float CDECL unix_exp2f( float x )
94 #ifdef HAVE_EXP2F
95 return exp2f(x);
96 #else
97 return unix_exp2(x);
98 #endif
101 /*********************************************************************
102 * fma
104 static double CDECL unix_fma( double x, double y, double z )
106 #ifdef HAVE_FMA
107 return fma(x, y, z);
108 #else
109 return x * y + z;
110 #endif
113 /*********************************************************************
114 * fmaf
116 static float CDECL unix_fmaf( float x, float y, float z )
118 #ifdef HAVE_FMAF
119 return fmaf(x, y, z);
120 #else
121 return x * y + z;
122 #endif
125 /*********************************************************************
126 * frexp
128 static double CDECL unix_frexp( double x, int *exp )
130 return frexp( x, exp );
133 /*********************************************************************
134 * frexpf
136 static float CDECL unix_frexpf( float x, int *exp )
138 return frexpf( x, exp );
141 /*********************************************************************
142 * hypot
144 static double CDECL unix_hypot(double x, double y)
146 return hypot( x, y );
149 /*********************************************************************
150 * hypotf
152 static float CDECL unix_hypotf(float x, float y)
154 return hypotf( x, y );
157 /*********************************************************************
158 * ldexp
160 static double CDECL unix_ldexp(double num, int exp)
162 return ldexp( num, exp );
165 /*********************************************************************
166 * lgamma
168 static double CDECL unix_lgamma(double x)
170 #ifdef HAVE_LGAMMA
171 return lgamma(x);
172 #else
173 FIXME( "not implemented\n" );
174 return 0;
175 #endif
178 /*********************************************************************
179 * lgammaf
181 static float CDECL unix_lgammaf(float x)
183 #ifdef HAVE_LGAMMAF
184 return lgammaf(x);
185 #else
186 FIXME( "not implemented\n" );
187 return 0;
188 #endif
191 /*********************************************************************
192 * log
194 static double CDECL unix_log( double x )
196 return log( x );
199 /*********************************************************************
200 * logf
202 static float CDECL unix_logf( float x )
204 return logf( x );
207 /*********************************************************************
208 * log10
210 static double CDECL unix_log10( double x )
212 return log10( x );
215 /*********************************************************************
216 * log10f
218 static float CDECL unix_log10f( float x )
220 return log10f( x );
223 /*********************************************************************
224 * log1p
226 static double CDECL unix_log1p(double x)
228 #ifdef HAVE_LOG1P
229 return log1p(x);
230 #else
231 return log(1 + x);
232 #endif
235 /*********************************************************************
236 * log1pf
238 static float CDECL unix_log1pf(float x)
240 #ifdef HAVE_LOG1PF
241 return log1pf(x);
242 #else
243 return log(1 + x);
244 #endif
247 /*********************************************************************
248 * log2
250 static double CDECL unix_log2(double x)
252 #ifdef HAVE_LOG2
253 return log2(x);
254 #else
255 return log(x) / log(2);
256 #endif
259 /*********************************************************************
260 * log2f
262 static float CDECL unix_log2f(float x)
264 #ifdef HAVE_LOG2F
265 return log2f(x);
266 #else
267 return unix_log2(x);
268 #endif
271 /*********************************************************************
272 * pow
274 static double CDECL unix_pow( double x, double y )
276 return pow( x, y );
279 /*********************************************************************
280 * powf
282 static float CDECL unix_powf( float x, float y )
284 return powf( x, y );
287 /*********************************************************************
288 * sinh
290 static double CDECL unix_sinh( double x )
292 return sinh( x );
295 /*********************************************************************
296 * sinhf
298 static float CDECL unix_sinhf( float x )
300 return sinhf( x );
303 /*********************************************************************
304 * tanh
306 static double CDECL unix_tanh( double x )
308 return tanh( x );
311 /*********************************************************************
312 * tanhf
314 static float CDECL unix_tanhf( float x )
316 return tanhf( x );
319 /*********************************************************************
320 * tgamma
322 static double CDECL unix_tgamma(double x)
324 #ifdef HAVE_TGAMMA
325 return tgamma(x);
326 #else
327 FIXME( "not implemented\n" );
328 return 0;
329 #endif
332 /*********************************************************************
333 * tgammaf
335 static float CDECL unix_tgammaf(float x)
337 #ifdef HAVE_TGAMMAF
338 return tgammaf(x);
339 #else
340 FIXME( "not implemented\n" );
341 return 0;
342 #endif
345 static const struct unix_funcs funcs =
347 unix_cosh,
348 unix_coshf,
349 unix_exp,
350 unix_expf,
351 unix_exp2,
352 unix_exp2f,
353 unix_fma,
354 unix_fmaf,
355 unix_frexp,
356 unix_frexpf,
357 unix_hypot,
358 unix_hypotf,
359 unix_ldexp,
360 unix_lgamma,
361 unix_lgammaf,
362 unix_log,
363 unix_logf,
364 unix_log10,
365 unix_log10f,
366 unix_log1p,
367 unix_log1pf,
368 unix_log2,
369 unix_log2f,
370 unix_pow,
371 unix_powf,
372 unix_sinh,
373 unix_sinhf,
374 unix_tanh,
375 unix_tanhf,
376 unix_tgamma,
377 unix_tgammaf,
380 NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
382 if (reason != DLL_PROCESS_ATTACH) return STATUS_SUCCESS;
383 TRACE( "\n" );
384 *(const struct unix_funcs **)ptr_out = &funcs;
385 return STATUS_SUCCESS;