Commit 20c53e72 authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent bfc3a2bd
......@@ -1791,7 +1791,7 @@
@ varargs sprintf(ptr str)
@ varargs sprintf_s(ptr long str)
@ cdecl sqrt(double)
@ cdecl -arch=!i386 sqrtf(float)
@ cdecl -arch=!i386 sqrtf(float) MSVCRT_sqrtf
@ cdecl srand(long)
@ varargs sscanf(str str)
@ varargs sscanf_s(str str)
......
......@@ -2149,7 +2149,7 @@
@ varargs sprintf(ptr str)
@ varargs sprintf_s(ptr long str)
@ cdecl sqrt(double)
@ cdecl -arch=!i386 sqrtf(float)
@ cdecl -arch=!i386 sqrtf(float) MSVCRT_sqrtf
@ cdecl srand(long)
@ varargs sscanf(str str)
@ varargs sscanf_s(str str)
......
......@@ -2360,7 +2360,7 @@
@ varargs sprintf(ptr str)
@ varargs sprintf_s(ptr long str)
@ cdecl sqrt(double)
@ cdecl -arch=!i386 sqrtf(float)
@ cdecl -arch=!i386 sqrtf(float) MSVCRT_sqrtf
@ cdecl srand(long)
@ varargs sscanf(str str)
@ varargs sscanf_s(str str)
......
......@@ -1472,7 +1472,7 @@
@ varargs sprintf(ptr str)
@ varargs sprintf_s(ptr long str)
@ cdecl sqrt(double)
@ cdecl -arch=!i386 sqrtf(float)
@ cdecl -arch=!i386 sqrtf(float) MSVCRT_sqrtf
@ cdecl srand(long)
@ varargs sscanf(str str)
@ varargs sscanf_s(str str)
......
......@@ -1444,7 +1444,7 @@
@ varargs sprintf(ptr str)
@ varargs sprintf_s(ptr long str)
@ cdecl sqrt(double)
@ cdecl -arch=!i386 sqrtf(float)
@ cdecl -arch=!i386 sqrtf(float) MSVCRT_sqrtf
@ cdecl srand(long)
@ varargs sscanf(str str)
@ varargs sscanf_s(str str)
......
......@@ -288,6 +288,7 @@ float CDECL MSVCRT_atanf( float x )
}
#endif
#ifdef __x86_64__
static BOOL sqrtf_validate( float *x )
{
short c = _fdclass(*x);
......@@ -303,7 +304,6 @@ static BOOL sqrtf_validate( float *x )
return TRUE;
}
#if defined(__x86_64__) || defined(__i386__)
float CDECL sse2_sqrtf(float);
__ASM_GLOBAL_FUNC( sse2_sqrtf,
"sqrtss %xmm0, %xmm0\n\t"
......@@ -312,10 +312,8 @@ __ASM_GLOBAL_FUNC( sse2_sqrtf,
/*********************************************************************
* sqrtf (MSVCRT.@)
*
* Copied from musl: src/math/sqrtf.c
*/
float CDECL sqrtf( float x )
float CDECL MSVCRT_sqrtf( float x )
{
#ifdef __x86_64__
if (!sqrtf_validate(&x))
......@@ -323,61 +321,7 @@ float CDECL sqrtf( float x )
return sse2_sqrtf(x);
#else
static const float tiny = 1.0e-30;
float z;
int ix,s,q,m,t,i;
unsigned int r;
ix = *(int*)&x;
if (!sqrtf_validate(&x))
return x;
/* normalize x */
m = ix >> 23;
if (m == 0) { /* subnormal x */
for (i = 0; (ix & 0x00800000) == 0; i++)
ix <<= 1;
m -= i - 1;
}
m -= 127; /* unbias exponent */
ix = (ix & 0x007fffff) | 0x00800000;
if (m & 1) /* odd m, double x to make it even */
ix += ix;
m >>= 1; /* m = [m/2] */
/* generate sqrt(x) bit by bit */
ix += ix;
q = s = 0; /* q = sqrt(x) */
r = 0x01000000; /* r = moving bit from right to left */
while (r != 0) {
t = s + r;
if (t <= ix) {
s = t + r;
ix -= t;
q += r;
}
ix += ix;
r >>= 1;
}
/* use floating add to find out rounding direction */
if (ix != 0) {
z = 1.0f - tiny; /* raise inexact flag */
if (z >= 1.0f) {
z = 1.0f + tiny;
if (z > 1.0f)
q += 2;
else
q += q & 1;
}
}
ix = (q >> 1) + 0x3f000000;
r = ix + ((unsigned int)m << 23);
z = *(float*)&r;
return z;
return sqrtf( x );
#endif
}
......
......@@ -1423,7 +1423,7 @@
@ varargs sprintf(ptr str)
@ varargs sprintf_s(ptr long str)
@ cdecl sqrt(double)
@ cdecl -arch=!i386 sqrtf(float)
@ cdecl -arch=!i386 sqrtf(float) MSVCRT_sqrtf
@ cdecl srand(long)
@ varargs sscanf(str str)
@ varargs sscanf_s(str str)
......
......@@ -1779,7 +1779,7 @@
@ cdecl _o_sinh(double) sinh
@ cdecl -arch=!i386 _o_sinhf(float) sinhf
@ cdecl _o_sqrt(double) sqrt
@ cdecl -arch=!i386 _o_sqrtf(float) sqrtf
@ cdecl -arch=!i386 _o_sqrtf(float) MSVCRT_sqrtf
@ cdecl _o_srand(long) srand
@ cdecl _o_strcat_s(str long str) strcat_s
@ cdecl _o_strcoll(str str) strcoll
......@@ -2495,7 +2495,7 @@
@ cdecl sinh(double)
@ cdecl -arch=!i386 sinhf(float)
@ cdecl sqrt(double)
@ cdecl -arch=!i386 sqrtf(float)
@ cdecl -arch=!i386 sqrtf(float) MSVCRT_sqrtf
@ cdecl srand(long)
@ cdecl strcat(str str)
@ cdecl strcat_s(str long str)
......
......@@ -24,7 +24,7 @@ float __cdecl sqrtf(float x)
if (ix == 0x7f800000)
return x;
if (ix > 0x7f800000)
return __math_invalidf(x);
return math_error(_DOMAIN, "sqrtf", x, 0, (x - x) / (x - x));
/* x is subnormal, normalize it. */
ix = asuint(x * 0x1p23f);
ix -= 23 << 23;
......
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