From 860c1578e6ed130792ff6a9c5e5431ec005472ac Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Wed, 12 Jul 2017 18:05:19 +0200 Subject: [PATCH] msvcr120: Add atanh. Signed-off-by: Alex Henrie Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- configure | 2 + configure.ac | 2 + .../api-ms-win-crt-math-l1-1-0.spec | 6 +- dlls/msvcr120/msvcr120.spec | 6 +- dlls/msvcr120_app/msvcr120_app.spec | 6 +- dlls/msvcrt/math.c | 66 +++++++++++++++++++ dlls/ucrtbase/ucrtbase.spec | 6 +- include/config.h.in | 6 ++ 8 files changed, 88 insertions(+), 12 deletions(-) diff --git a/configure b/configure index 199d4d8b11d..95cfa25e386 100755 --- a/configure +++ b/configure @@ -17410,6 +17410,8 @@ for ac_func in \ acoshf \ asinh \ asinhf \ + atanh \ + atanhf \ cbrt \ cbrtf \ erf \ diff --git a/configure.ac b/configure.ac index 3974dd5818e..77b04b9c162 100644 --- a/configure.ac +++ b/configure.ac @@ -2598,6 +2598,8 @@ AC_CHECK_FUNCS(\ acoshf \ asinh \ asinhf \ + atanh \ + atanhf \ cbrt \ cbrtf \ erf \ diff --git a/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec b/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec index 5c644326ced..fb5c35059fd 100644 --- a/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec +++ b/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec @@ -136,9 +136,9 @@ @ cdecl atan2(double double) ucrtbase.atan2 @ cdecl -arch=arm,x86_64 atan2f(float float) ucrtbase.atan2f @ cdecl -arch=arm,x86_64 atanf(float) ucrtbase.atanf -@ stub atanh -@ stub atanhf -@ stub atanhl +@ cdecl atanh(double) ucrtbase.atanh +@ cdecl atanhf(float) ucrtbase.atanhf +@ cdecl atanhl(double) ucrtbase.atanhl @ stub cabs @ stub cabsf @ stub cabsl diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index 7899622f69c..323d5f43c01 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -2025,9 +2025,9 @@ @ cdecl -arch=arm,x86_64 atanf(float) MSVCRT_atanf @ cdecl atan2(double double) MSVCRT_atan2 @ cdecl -arch=arm,x86_64 atan2f(float float) MSVCRT_atan2f -@ stub atanh -@ stub atanhf -@ stub atanhl +@ cdecl atanh(double) MSVCR120_atanh +@ cdecl atanhf(float) MSVCR120_atanhf +@ cdecl atanhl(double) MSVCR120_atanhl @ cdecl -private atexit(ptr) MSVCRT_atexit # not imported to avoid conflicts with Mingw @ cdecl atof(str) MSVCRT_atof @ cdecl atoi(str) MSVCRT_atoi diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec index 9a5da20ca8b..73101c74379 100644 --- a/dlls/msvcr120_app/msvcr120_app.spec +++ b/dlls/msvcr120_app/msvcr120_app.spec @@ -1691,9 +1691,9 @@ @ cdecl -arch=arm,x86_64 atanf(float) msvcr120.atanf @ cdecl atan2(double double) msvcr120.atan2 @ cdecl -arch=arm,x86_64 atan2f(float float) msvcr120.atan2f -@ stub atanh -@ stub atanhf -@ stub atanhl +@ cdecl atanh(double) msvcr120.atanh +@ cdecl atanhf(float) msvcr120.atanhf +@ cdecl atanhl(double) msvcr120.atanhl @ cdecl -private atexit(ptr) msvcr120.atexit @ cdecl atof(str) msvcr120.atof @ cdecl atoi(str) msvcr120.atoi diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 17edf47dfaa..9eed9b8b897 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -2943,6 +2943,72 @@ LDOUBLE CDECL MSVCR120_acoshl(LDOUBLE x) return MSVCR120_acosh(x); } +/********************************************************************* + * atanh (MSVCR120.@) + */ +double CDECL MSVCR120_atanh(double x) +{ + double ret; + + if (x > 1 || x < -1) { + MSVCRT_fenv_t env; + + *MSVCRT__errno() = MSVCRT_EDOM; + + /* on Linux atanh returns -NAN in this case */ + MSVCRT_fegetenv(&env); + env.status |= MSVCRT__SW_INVALID; + MSVCRT_fesetenv(&env); + return NAN; + } + +#ifdef HAVE_ATANH + ret = atanh(x); +#else + if (-1e-6 < x && x < 1e-6) ret = x + x*x*x/3; + else ret = (log(1+x) - log(1-x)) / 2; +#endif + + if (!isfinite(ret)) *MSVCRT__errno() = MSVCRT_ERANGE; + return ret; +} + +/********************************************************************* + * atanhf (MSVCR120.@) + */ +float CDECL MSVCR120_atanhf(float x) +{ +#ifdef HAVE_ATANHF + double ret; + + if (x > 1 || x < -1) { + MSVCRT_fenv_t env; + + *MSVCRT__errno() = MSVCRT_EDOM; + + MSVCRT_fegetenv(&env); + env.status |= MSVCRT__SW_INVALID; + MSVCRT_fesetenv(&env); + return NAN; + } + + ret = atanhf(x); + + if (!isfinite(ret)) *MSVCRT__errno() = MSVCRT_ERANGE; + return ret; +#else + return MSVCR120_atanh(x); +#endif +} + +/********************************************************************* + * atanhl (MSVCR120.@) + */ +LDOUBLE CDECL MSVCR120_atanhl(LDOUBLE x) +{ + return MSVCR120_atanh(x); +} + /********************************************************************* * _scalb (MSVCRT.@) * scalbn (MSVCR120.@) diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index 1eae07222d7..aacf3614daf 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -2167,9 +2167,9 @@ @ cdecl atan2(double double) MSVCRT_atan2 @ cdecl -arch=arm,x86_64 atan2f(float float) MSVCRT_atan2f @ cdecl -arch=arm,x86_64 atanf(float) MSVCRT_atanf -@ stub atanh -@ stub atanhf -@ stub atanhl +@ cdecl atanh(double) MSVCR120_atanh +@ cdecl atanhf(float) MSVCR120_atanhf +@ cdecl atanhl(double) MSVCR120_atanhl @ cdecl atof(str) MSVCRT_atof @ cdecl atoi(str) MSVCRT_atoi @ cdecl atol(str) ntdll.atol diff --git a/include/config.h.in b/include/config.h.in index 4a9acca5471..2e909fdf975 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -50,6 +50,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ASM_USER_H +/* Define to 1 if you have the `atanh' function. */ +#undef HAVE_ATANH + +/* Define to 1 if you have the `atanhf' function. */ +#undef HAVE_ATANHF + /* Define to 1 if you have the header file. */ #undef HAVE_AUDIOTOOLBOX_AUDIOCONVERTER_H