From: Alexandre Julliard julliard@winehq.org
--- dlls/crtdll/crtdll.spec | 2 +- dlls/msvcr100/msvcr100.spec | 2 +- dlls/msvcr110/msvcr110.spec | 2 +- dlls/msvcr120/msvcr120.spec | 2 +- dlls/msvcr70/msvcr70.spec | 2 +- dlls/msvcr71/msvcr71.spec | 2 +- dlls/msvcr80/msvcr80.spec | 2 +- dlls/msvcr90/msvcr90.spec | 2 +- dlls/msvcrt/math.c | 92 ++++++------------------------------- dlls/msvcrt/msvcrt.spec | 2 +- dlls/msvcrtd/msvcrtd.spec | 2 +- dlls/ucrtbase/ucrtbase.spec | 4 +- libs/musl/src/math/asin.c | 2 +- 13 files changed, 27 insertions(+), 91 deletions(-)
diff --git a/dlls/crtdll/crtdll.spec b/dlls/crtdll/crtdll.spec index 0e863362f77..b870eef8845 100644 --- a/dlls/crtdll/crtdll.spec +++ b/dlls/crtdll/crtdll.spec @@ -346,7 +346,7 @@ @ cdecl abs(long) @ cdecl acos(double) @ cdecl asctime(ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl atan(double) @ cdecl atan2(double double) @ cdecl -private atexit(ptr) MSVCRT_atexit diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index abae3f4b301..16ece69f1a4 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1630,7 +1630,7 @@ @ cdecl -arch=!i386 acosf(float) @ cdecl asctime(ptr) @ cdecl asctime_s(ptr long ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl -arch=!i386 asinf(float) @ cdecl atan(double) @ cdecl -arch=!i386 atanf(float) diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec index e83ce328928..d4d696f512e 100644 --- a/dlls/msvcr110/msvcr110.spec +++ b/dlls/msvcr110/msvcr110.spec @@ -1987,7 +1987,7 @@ @ cdecl -arch=!i386 acosf(float) @ cdecl asctime(ptr) @ cdecl asctime_s(ptr long ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl -arch=!i386 asinf(float) @ cdecl atan(double) @ cdecl -arch=!i386 atanf(float) diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index ec1fd48dce5..33bd6efb73e 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -2017,7 +2017,7 @@ @ cdecl acoshl(double) acosh @ cdecl asctime(ptr) @ cdecl asctime_s(ptr long ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl -arch=!i386 asinf(float) @ cdecl asinh(double) @ cdecl asinhf(float) diff --git a/dlls/msvcr70/msvcr70.spec b/dlls/msvcr70/msvcr70.spec index 3300cf36bf3..cf2a57c5578 100644 --- a/dlls/msvcr70/msvcr70.spec +++ b/dlls/msvcr70/msvcr70.spec @@ -688,7 +688,7 @@ @ cdecl abs(long) @ cdecl acos(double) @ cdecl asctime(ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl atan(double) @ cdecl atan2(double double) @ cdecl -private atexit(ptr) MSVCRT_atexit # not imported to avoid conflicts with Mingw diff --git a/dlls/msvcr71/msvcr71.spec b/dlls/msvcr71/msvcr71.spec index 5b68d3217af..1ef2ec942e4 100644 --- a/dlls/msvcr71/msvcr71.spec +++ b/dlls/msvcr71/msvcr71.spec @@ -684,7 +684,7 @@ @ cdecl abs(long) @ cdecl acos(double) @ cdecl asctime(ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl atan(double) @ cdecl atan2(double double) @ cdecl -private atexit(ptr) MSVCRT_atexit # not imported to avoid conflicts with Mingw diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 7c7c2f8bcdb..88c4a32d52f 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -1313,7 +1313,7 @@ @ cdecl -arch=!i386 acosf(float) @ cdecl asctime(ptr) @ cdecl asctime_s(ptr long ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl -arch=!i386 asinf(float) @ cdecl atan(double) @ cdecl -arch=!i386 atanf(float) diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index c1e4a406265..bd5b3126f30 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -1285,7 +1285,7 @@ @ cdecl -arch=!i386 acosf(float) @ cdecl asctime(ptr) @ cdecl asctime_s(ptr long ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl atan(double) @ cdecl atan2(double double) @ cdecl -arch=!i386 asinf(float) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 32ee44fa246..69dfca332af 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -445,29 +445,7 @@ float CDECL tanhf( float x )
/********************************************************************* * asin (MSVCRT.@) - * - * Copied from musl: src/math/asin.c */ -static double asin_R(double z) -{ - /* coefficients for R(x^2) */ - static const double pS0 = 1.66666666666666657415e-01, - pS1 = -3.25565818622400915405e-01, - pS2 = 2.01212532134862925881e-01, - pS3 = -4.00555345006794114027e-02, - pS4 = 7.91534994289814532176e-04, - pS5 = 3.47933107596021167570e-05, - qS1 = -2.40339491173441421878e+00, - qS2 = 2.02094576023350569471e+00, - qS3 = -6.88283971605453293030e-01, - qS4 = 7.70381505559019352791e-02; - - double p, q; - p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5))))); - q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4))); - return p / q; -} - #ifdef __i386__ double CDECL x87_asin(double); __ASM_GLOBAL_FUNC( x87_asin, @@ -485,70 +463,28 @@ __ASM_GLOBAL_FUNC( x87_asin, "ret" ) #endif
-double CDECL asin( double x ) +double CDECL MSVCRT_asin( double x ) { - static const double pio2_hi = 1.57079632679489655800e+00, - pio2_lo = 6.12323399573676603587e-17; - - double z, r, s; - unsigned int hx, ix; - ULONGLONG llx; #ifdef __i386__ unsigned int x87_cw, sse2_cw; -#endif + unsigned int hx = *(ULONGLONG*)&x >> 32; + unsigned int ix = hx & 0x7fffffff;
- hx = *(ULONGLONG*)&x >> 32; - ix = hx & 0x7fffffff; - /* |x| >= 1 or nan */ - if (ix >= 0x3ff00000) { - unsigned int lx; - lx = *(ULONGLONG*)&x; - if (((ix - 0x3ff00000) | lx) == 0) - /* asin(1) = +-pi/2 with inexact */ - return x * pio2_hi + 7.5231638452626401e-37; - if (isnan(x)) - { -#ifdef __i386__ - return math_error(_DOMAIN, "asin", x, 0, x); -#else - return x; -#endif - } - return math_error(_DOMAIN, "asin", x, 0, 0 / (x - x)); - } + if (isnan(x)) return math_error(_DOMAIN, "asin", x, 0, x);
-#ifdef __i386__ - __control87_2(0, 0, &x87_cw, &sse2_cw); - if (!sse2_enabled || (x87_cw & _MCW_EM) != _MCW_EM + /* |x| < 1 */ + if (ix < 0x3ff00000) + { + __control87_2(0, 0, &x87_cw, &sse2_cw); + if (!sse2_enabled || (x87_cw & _MCW_EM) != _MCW_EM || (sse2_cw & (_MCW_EM | _MCW_RC)) != _MCW_EM) - return x87_asin(x); + return x87_asin(x); + } +#else + if (isnan(x)) return x; #endif
- /* |x| < 0.5 */ - if (ix < 0x3fe00000) { - /* if 0x1p-1022 <= |x| < 0x1p-26, avoid raising underflow */ - if (ix < 0x3e500000 && ix >= 0x00100000) - return x; - return x + x * asin_R(x * x); - } - /* 1 > |x| >= 0.5 */ - z = (1 - fabs(x)) * 0.5; - s = sqrt(z); - r = asin_R(z); - if (ix >= 0x3fef3333) { /* if |x| > 0.975 */ - x = pio2_hi - (2 * (s + s * r) - pio2_lo); - } else { - double f, c; - /* f+c = sqrt(z) */ - f = s; - llx = (*(ULONGLONG*)&f >> 32) << 32; - f = *(double*)&llx; - c = (z - f * f) / (s + f); - x = 0.5 * pio2_hi - (2 * s * r - (pio2_lo - 2 * c) - (0.5 * pio2_hi - 2 * f)); - } - if (hx >> 31) - return -x; - return x; + return asin( x ); }
/********************************************************************* diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index aaca212c63c..2d3e27be81a 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -1253,7 +1253,7 @@ @ cdecl -arch=!i386 acosf(float) @ cdecl asctime(ptr) @ cdecl asctime_s(ptr long ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl atan(double) @ cdecl atan2(double double) @ cdecl -arch=!i386 asinf(float) diff --git a/dlls/msvcrtd/msvcrtd.spec b/dlls/msvcrtd/msvcrtd.spec index 2c3f4912a03..09c0a947683 100644 --- a/dlls/msvcrtd/msvcrtd.spec +++ b/dlls/msvcrtd/msvcrtd.spec @@ -641,7 +641,7 @@ @ cdecl abs(long) @ cdecl acos(double) @ cdecl asctime(ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl atan(double) @ cdecl atan2(double double) @ cdecl -private atexit(ptr) MSVCRT_atexit diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index a05023b9f3e..45d883d410c 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -1567,7 +1567,7 @@ @ cdecl _o_acoshl(double) acosh @ cdecl _o_asctime(ptr) asctime @ cdecl _o_asctime_s(ptr long ptr) asctime_s -@ cdecl _o_asin(double) asin +@ cdecl _o_asin(double) MSVCRT_asin @ cdecl -arch=!i386 _o_asinf(float) asinf @ cdecl _o_asinh(double) asinh @ cdecl _o_asinhf(float) asinhf @@ -2161,7 +2161,7 @@ @ cdecl acoshl(double) acosh @ cdecl asctime(ptr) @ cdecl asctime_s(ptr long ptr) -@ cdecl asin(double) +@ cdecl asin(double) MSVCRT_asin @ cdecl -arch=!i386 asinf(float) @ cdecl asinh(double) @ cdecl asinhf(float) diff --git a/libs/musl/src/math/asin.c b/libs/musl/src/math/asin.c index 0ff68c07899..0686522f0f7 100644 --- a/libs/musl/src/math/asin.c +++ b/libs/musl/src/math/asin.c @@ -78,7 +78,7 @@ double __cdecl asin(double x) if ((ix-0x3ff00000 | lx) == 0) /* asin(1) = +-pi/2 with inexact */ return x*pio2_hi + 0x1p-120f; - return 0/(x-x); + return math_error(_DOMAIN, "asin", x, 0, 0 / (x - x)); } /* |x| < 0.5 */ if (ix < 0x3fe00000) {