Commit 48028c64 authored by Alexandre Julliard's avatar Alexandre Julliard

msvcrt: Import ilogb() from musl.

parent 44e122e0
......@@ -19512,8 +19512,6 @@ for ac_func in \
expm1f \
fma \
fmaf \
ilogb \
ilogbf \
j0 \
j1 \
jn \
......
......@@ -2698,8 +2698,6 @@ AC_CHECK_FUNCS(\
expm1f \
fma \
fmaf \
ilogb \
ilogbf \
j0 \
j1 \
jn \
......
......@@ -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);
......
......@@ -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
......
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