msvcrt: Import log2 implementation from musl.
[wine.git] / dlls / msvcrt / unixlib.c
blob440d002869cf54bb234ec696c07c1a9fa4deaa3c
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 * exp
48 static double CDECL unix_exp( double x )
50 return exp( x );
53 /*********************************************************************
54 * expf
56 static float CDECL unix_expf( float x )
58 return expf( x );
61 /*********************************************************************
62 * exp2
64 static double CDECL unix_exp2( double x )
66 #ifdef HAVE_EXP2
67 return exp2(x);
68 #else
69 return pow(2, x);
70 #endif
73 /*********************************************************************
74 * exp2f
76 static float CDECL unix_exp2f( float x )
78 #ifdef HAVE_EXP2F
79 return exp2f(x);
80 #else
81 return unix_exp2(x);
82 #endif
85 /*********************************************************************
86 * fmaf
88 static float CDECL unix_fmaf( float x, float y, float z )
90 #ifdef HAVE_FMAF
91 return fmaf(x, y, z);
92 #else
93 return x * y + z;
94 #endif
97 /*********************************************************************
98 * lgamma
100 static double CDECL unix_lgamma(double x)
102 #ifdef HAVE_LGAMMA
103 return lgamma(x);
104 #else
105 FIXME( "not implemented\n" );
106 return 0;
107 #endif
110 /*********************************************************************
111 * lgammaf
113 static float CDECL unix_lgammaf(float x)
115 #ifdef HAVE_LGAMMAF
116 return lgammaf(x);
117 #else
118 FIXME( "not implemented\n" );
119 return 0;
120 #endif
123 /*********************************************************************
124 * pow
126 static double CDECL unix_pow( double x, double y )
128 return pow( x, y );
131 /*********************************************************************
132 * powf
134 static float CDECL unix_powf( float x, float y )
136 return powf( x, y );
139 /*********************************************************************
140 * tgamma
142 static double CDECL unix_tgamma(double x)
144 #ifdef HAVE_TGAMMA
145 return tgamma(x);
146 #else
147 FIXME( "not implemented\n" );
148 return 0;
149 #endif
152 /*********************************************************************
153 * tgammaf
155 static float CDECL unix_tgammaf(float x)
157 #ifdef HAVE_TGAMMAF
158 return tgammaf(x);
159 #else
160 FIXME( "not implemented\n" );
161 return 0;
162 #endif
165 static const struct unix_funcs funcs =
167 unix_exp,
168 unix_expf,
169 unix_exp2,
170 unix_exp2f,
171 unix_fmaf,
172 unix_lgamma,
173 unix_lgammaf,
174 unix_pow,
175 unix_powf,
176 unix_tgamma,
177 unix_tgammaf,
180 NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
182 if (reason != DLL_PROCESS_ATTACH) return STATUS_SUCCESS;
183 TRACE( "\n" );
184 *(const struct unix_funcs **)ptr_out = &funcs;
185 return STATUS_SUCCESS;