msvcrt: Import ilogb() from musl.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-11-17 09:59:54 +01:00
parent 44e122e04e
commit 48028c64ea
4 changed files with 37 additions and 26 deletions

2
configure vendored
View File

@ -19512,8 +19512,6 @@ for ac_func in \
expm1f \
fma \
fmaf \
ilogb \
ilogbf \
j0 \
j1 \
jn \

View File

@ -2698,8 +2698,6 @@ AC_CHECK_FUNCS(\
expm1f \
fma \
fmaf \
ilogb \
ilogbf \
j0 \
j1 \
jn \

View File

@ -4402,32 +4402,53 @@ double CDECL MSVCR120_creal(_Dcomplex z)
return z.x;
}
/*********************************************************************
* ilogb (MSVCR120.@)
*
* Copied from musl: src/math/ilogb.c
*/
int CDECL MSVCR120_ilogb(double x)
{
if (!x) return MSVCRT_FP_ILOGB0;
if (isnan(x)) return MSVCRT_FP_ILOGBNAN;
if (isinf(x)) return MSVCRT_INT_MAX;
union { double f; UINT64 i; } u = { x };
int e = u.i >> 52 & 0x7ff;
#ifdef HAVE_ILOGB
return ilogb(x);
#else
return logb(x);
#endif
if (!e)
{
u.i <<= 12;
if (u.i == 0) return MSVCRT_FP_ILOGB0;
/* subnormal x */
for (e = -0x3ff; u.i >> 63 == 0; e--, u.i <<= 1);
return e;
}
if (e == 0x7ff) return u.i << 12 ? MSVCRT_FP_ILOGBNAN : MSVCRT_INT_MAX;
return e - 0x3ff;
}
/*********************************************************************
* ilogbf (MSVCR120.@)
*
* Copied from musl: src/math/ilogbf.c
*/
int CDECL MSVCR120_ilogbf(float x)
{
if (!x) return MSVCRT_FP_ILOGB0;
if (isnan(x)) return MSVCRT_FP_ILOGBNAN;
if (isinf(x)) return MSVCRT_INT_MAX;
union { float f; UINT32 i; } u = { x };
int e = u.i >> 23 & 0xff;
#ifdef HAVE_ILOGBF
return ilogbf(x);
#else
return logbf(x);
#endif
if (!e)
{
u.i <<= 9;
if (u.i == 0) return MSVCRT_FP_ILOGB0;
/* subnormal x */
for (e = -0x7f; u.i >> 31 == 0; e--, u.i <<= 1);
return e;
}
if (e == 0xff) return u.i << 9 ? MSVCRT_FP_ILOGBNAN : MSVCRT_INT_MAX;
return e - 0x7f;
}
/*********************************************************************
* ilogbl (MSVCR120.@)
*/
int CDECL MSVCR120_ilogbl(LDOUBLE x)
{
return MSVCR120_ilogb(x);

View File

@ -288,12 +288,6 @@
/* Define to 1 if you have the `if_nameindex' function. */
#undef HAVE_IF_NAMEINDEX
/* Define to 1 if you have the `ilogb' function. */
#undef HAVE_ILOGB
/* Define to 1 if you have the `ilogbf' function. */
#undef HAVE_ILOGBF
/* Define to 1 if you have the <inet/mib2.h> header file. */
#undef HAVE_INET_MIB2_H