msvcrt: Import truncf implementation from musl.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2021-05-17 15:38:18 +02:00 committed by Alexandre Julliard
parent 29c07324c1
commit 5544e6de07
6 changed files with 17 additions and 22 deletions

3
configure vendored
View File

@ -19644,8 +19644,7 @@ for ac_func in \
remquof \
tgamma \
tgammaf \
trunc \
truncf
trunc
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`

View File

@ -2684,8 +2684,7 @@ AC_CHECK_FUNCS(\
remquof \
tgamma \
tgammaf \
trunc \
truncf
trunc
)
LIBS="$ac_save_LIBS"

View File

@ -4989,10 +4989,24 @@ double CDECL trunc(double x)
/*********************************************************************
* truncf (MSVCR120.@)
*
* Copied from musl: src/math/truncf.c
*/
float CDECL truncf(float x)
{
return unix_funcs->truncf(x);
union {float f; UINT32 i;} u = {x};
int e = (u.i >> 23 & 0xff) - 0x7f + 9;
UINT32 m;
if (e >= 23 + 9)
return x;
if (e < 9)
e = 1;
m = -1U >> e;
if ((u.i & m) == 0)
return x;
u.i &= ~m;
return u.f;
}
/*********************************************************************

View File

@ -648,18 +648,6 @@ static double CDECL unix_trunc(double x)
#endif
}
/*********************************************************************
* truncf
*/
static float CDECL unix_truncf(float x)
{
#ifdef HAVE_TRUNCF
return truncf(x);
#else
return unix_trunc(x);
#endif
}
/*********************************************************************
* tgammaf
*/
@ -735,7 +723,6 @@ static const struct unix_funcs funcs =
unix_tgamma,
unix_tgammaf,
unix_trunc,
unix_truncf
};
NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )

View File

@ -83,7 +83,6 @@ struct unix_funcs
double (CDECL *tgamma)(double x);
float (CDECL *tgammaf)(float x);
double (CDECL *trunc)(double x);
float (CDECL *truncf)(float x);
};
#endif /* __UNIXLIB_H */

View File

@ -1013,9 +1013,6 @@
/* Define to 1 if you have the `trunc' function. */
#undef HAVE_TRUNC
/* Define to 1 if you have the `truncf' function. */
#undef HAVE_TRUNCF
/* Define to 1 if you have the `udev' library (-ludev). */
#undef HAVE_UDEV