Commit 472d7ec7 authored by Alexandre Julliard's avatar Alexandre Julliard

msvcrt: Use the asinf() implementation from the bundled musl library.

With the changes from 0b8db612.
parent c9399ae7
......@@ -290,61 +290,6 @@ int CDECL _isnanf( float num )
return (u.i & 0x7fffffff) > 0x7f800000;
}
static float asinf_R(float z)
{
/* coefficients for R(x^2) */
static const float p1 = 1.66666672e-01,
p2 = -5.11644611e-02,
p3 = -1.21124933e-02,
p4 = -3.58742251e-03,
q1 = -7.56982703e-01;
float p, q;
p = z * (p1 + z * (p2 + z * (p3 + z * p4)));
q = 1.0f + z * q1;
return p / q;
}
/*********************************************************************
* asinf (MSVCRT.@)
*
* Copied from musl: src/math/asinf.c
*/
float CDECL asinf( float x )
{
static const double pio2 = 1.570796326794896558e+00;
static const float pio4_hi = 0.785398125648;
static const float pio2_lo = 7.54978941586e-08;
float s, z, f, c;
unsigned int hx, ix;
hx = *(unsigned int*)&x;
ix = hx & 0x7fffffff;
if (ix >= 0x3f800000) { /* |x| >= 1 */
if (ix == 0x3f800000) /* |x| == 1 */
return x * pio2 + 7.5231638453e-37; /* asin(+-1) = +-pi/2 with inexact */
if (isnan(x)) return x;
return math_error(_DOMAIN, "asinf", x, 0, 0 / (x - x));
}
if (ix < 0x3f000000) { /* |x| < 0.5 */
/* if 0x1p-126 <= |x| < 0x1p-12, avoid raising underflow */
if (ix < 0x39800000 && ix >= 0x00800000)
return x;
return x + x * asinf_R(x * x);
}
/* 1 > |x| >= 0.5 */
z = (1 - fabsf(x)) * 0.5f;
s = sqrtf(z);
/* f+c = sqrt(z) */
*(unsigned int*)&f = *(unsigned int*)&s & 0xffff0000;
c = (z - f * f) / (s + f);
x = pio4_hi - (2 * s * asinf_R(z) - (pio2_lo - 2 * c) - (pio4_hi - 2 * f));
if (hx >> 31)
return -x;
return x;
}
/*********************************************************************
* atanf (MSVCRT.@)
*
......
......@@ -18,24 +18,26 @@ static const double
pio2 = 1.570796326794896558e+00;
static const float
pio4_hi = 0.785398125648,
pio2_lo = 7.54978941586e-08,
/* coefficients for R(x^2) */
pS0 = 1.6666586697e-01,
pS1 = -4.2743422091e-02,
pS2 = -8.6563630030e-03,
qS1 = -7.0662963390e-01;
pS0 = 1.66666672e-01,
pS1 = -5.11644611e-02,
pS2 = -1.21124933e-02,
pS3 = -3.58742251e-03,
qS1 = -7.56982703e-01;
static float R(float z)
{
float_t p, q;
p = z*(pS0+z*(pS1+z*pS2));
p = z*(pS0+z*(pS1+z*(pS2+z*pS3)));
q = 1.0f+z*qS1;
return p/q;
}
float __cdecl asinf(float x)
{
double s;
float z;
float s, z, f, c;
uint32_t hx,ix;
GET_FLOAT_WORD(hx, x);
......@@ -43,7 +45,8 @@ float __cdecl asinf(float x)
if (ix >= 0x3f800000) { /* |x| >= 1 */
if (ix == 0x3f800000) /* |x| == 1 */
return x*pio2 + 0x1p-120f; /* asin(+-1) = +-pi/2 with inexact */
return 0/(x-x); /* asin(|x|>1) is NaN */
if (isnan(x)) return x;
return math_error(_DOMAIN, "asinf", x, 0, 0 / (x - x));
}
if (ix < 0x3f000000) { /* |x| < 0.5 */
/* if 0x1p-126 <= |x| < 0x1p-12, avoid raising underflow */
......@@ -53,8 +56,11 @@ float __cdecl asinf(float x)
}
/* 1 > |x| >= 0.5 */
z = (1 - fabsf(x))*0.5f;
s = sqrt(z);
x = pio2 - 2*(s+s*R(z));
s = sqrtf(z);
/* f+c = sqrt(z) */
*(unsigned int*)&f = *(unsigned int*)&s & 0xffff0000;
c = (z - f * f) / (s + f);
x = pio4_hi - (2*s*R(z) - (pio2_lo - 2*c) - (pio4_hi - 2*f));
if (hx >> 31)
return -x;
return x;
......
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