Commit f2c18726 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Import trunc implementation from musl.

parent 5544e6de
......@@ -19643,8 +19643,7 @@ for ac_func in \
remquo \
remquof \
tgamma \
tgammaf \
trunc
tgammaf
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
......
......@@ -2683,8 +2683,7 @@ AC_CHECK_FUNCS(\
remquo \
remquof \
tgamma \
tgammaf \
trunc
tgammaf
)
LIBS="$ac_save_LIBS"
......
......@@ -4981,10 +4981,24 @@ __int64 CDECL llroundf(float x)
/*********************************************************************
* trunc (MSVCR120.@)
*
* Copied from musl: src/math/trunc.c
*/
double CDECL trunc(double x)
{
return unix_funcs->trunc(x);
union {double f; UINT64 i;} u = {x};
int e = (u.i >> 52 & 0x7ff) - 0x3ff + 12;
UINT64 m;
if (e >= 52 + 12)
return x;
if (e < 12)
e = 1;
m = -1ULL >> e;
if ((u.i & m) == 0)
return x;
u.i &= ~m;
return u.f;
}
/*********************************************************************
......
......@@ -637,18 +637,6 @@ static double CDECL unix_tgamma(double x)
}
/*********************************************************************
* trunc
*/
static double CDECL unix_trunc(double x)
{
#ifdef HAVE_TRUNC
return trunc(x);
#else
return (x > 0) ? floor(x) : ceil(x);
#endif
}
/*********************************************************************
* tgammaf
*/
static float CDECL unix_tgammaf(float x)
......@@ -722,7 +710,6 @@ static const struct unix_funcs funcs =
unix_tanhf,
unix_tgamma,
unix_tgammaf,
unix_trunc,
};
NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
......
......@@ -82,7 +82,6 @@ struct unix_funcs
float (CDECL *tanhf)(float x);
double (CDECL *tgamma)(double x);
float (CDECL *tgammaf)(float x);
double (CDECL *trunc)(double x);
};
#endif /* __UNIXLIB_H */
......@@ -1010,9 +1010,6 @@
/* Define to 1 if you have the <tiffio.h> header file. */
#undef HAVE_TIFFIO_H
/* Define to 1 if you have the `trunc' function. */
#undef HAVE_TRUNC
/* Define to 1 if you have the `udev' library (-ludev). */
#undef HAVE_UDEV
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment