From e38b46e7f7250e4e7c8d7979a845cdc1106677be Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Thu, 1 Aug 2019 22:52:26 +0300 Subject: [PATCH] msvcrt: Implement the tgamma functions. Signed-off-by: Martin Storsjo 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 | 38 +++++++++++++++++++ dlls/ucrtbase/ucrtbase.spec | 6 +-- include/config.h.in | 6 +++ 8 files changed, 60 insertions(+), 12 deletions(-) diff --git a/configure b/configure index ed561670a35..44e283e01ea 100755 --- a/configure +++ b/configure @@ -19289,6 +19289,8 @@ for ac_func in \ rintf \ round \ roundf \ + tgamma \ + tgammaf \ trunc \ truncf \ y0 \ diff --git a/configure.ac b/configure.ac index 0fe26022b7d..c58d34330e4 100644 --- a/configure.ac +++ b/configure.ac @@ -2676,6 +2676,8 @@ AC_CHECK_FUNCS(\ rintf \ round \ roundf \ + tgamma \ + tgammaf \ trunc \ truncf \ y0 \ 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 73967eaa060..eb7017f2f56 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 @@ -333,9 +333,9 @@ @ cdecl -arch=arm,x86_64,arm64 tanf(float) ucrtbase.tanf @ cdecl tanh(double) ucrtbase.tanh @ cdecl -arch=arm,x86_64,arm64 tanhf(float) ucrtbase.tanhf -@ stub tgamma -@ stub tgammaf -@ stub tgammal +@ cdecl tgamma(double) ucrtbase.tgamma +@ cdecl tgammaf(float) ucrtbase.tgammaf +@ cdecl tgammal(double) ucrtbase.tgammal @ cdecl trunc(double) ucrtbase.trunc @ cdecl truncf(float) ucrtbase.truncf @ cdecl truncl(double) ucrtbase.truncl diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index d7c5843caed..469bc0100e9 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -2405,9 +2405,9 @@ @ cdecl -arch=arm,x86_64,arm64 tanf(float) MSVCRT_tanf @ cdecl tanh(double) MSVCRT_tanh @ cdecl -arch=arm,x86_64,arm64 tanhf(float) MSVCRT_tanhf -@ stub tgamma -@ stub tgammaf -@ stub tgammal +@ cdecl tgamma(double) MSVCR120_tgamma +@ cdecl tgammaf(float) MSVCR120_tgammaf +@ cdecl tgammal(double) MSVCR120_tgamma @ cdecl tmpfile() MSVCRT_tmpfile @ cdecl tmpfile_s(ptr) MSVCRT_tmpfile_s @ cdecl tmpnam(ptr) MSVCRT_tmpnam diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec index 2dcf1917194..f9e3a0087f4 100644 --- a/dlls/msvcr120_app/msvcr120_app.spec +++ b/dlls/msvcr120_app/msvcr120_app.spec @@ -2067,9 +2067,9 @@ @ cdecl -arch=arm,x86_64,arm64 tanf(float) msvcr120.tanf @ cdecl tanh(double) msvcr120.tanh @ cdecl -arch=arm,x86_64,arm64 tanhf(float) msvcr120.tanhf -@ stub tgamma -@ stub tgammaf -@ stub tgammal +@ cdecl tgamma(double) msvcr120.tgamma +@ cdecl tgammaf(float) msvcr120.tgammaf +@ cdecl tgammal(double) msvcr120.tgammal @ cdecl tmpfile() msvcr120.tmpfile @ cdecl tmpfile_s(ptr) msvcr120.tmpfile_s @ cdecl tmpnam(ptr) msvcr120.tmpnam diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 841a2313ed1..6651df8c123 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -3404,6 +3404,44 @@ LDOUBLE CDECL MSVCR120_lgammal(LDOUBLE x) return MSVCR120_lgamma(x); } +/********************************************************************* + * tgamma (MSVCR120.@) + */ +double CDECL MSVCR120_tgamma(double x) +{ +#ifdef HAVE_TGAMMA + if(x==0.0) *MSVCRT__errno() = MSVCRT_ERANGE; + if(x<0.0f) { + double integral; + if (modf(x, &integral) == 0) + *MSVCRT__errno() = MSVCRT_EDOM; + } + return tgamma(x); +#else + FIXME( "not implemented\n" ); + return 0.0; +#endif +} + +/********************************************************************* + * tgammaf (MSVCR120.@) + */ +float CDECL MSVCR120_tgammaf(float x) +{ +#ifdef HAVE_TGAMMAF + if(x==0.0f) *MSVCRT__errno() = MSVCRT_ERANGE; + if(x<0.0f) { + float integral; + if (modff(x, &integral) == 0) + *MSVCRT__errno() = MSVCRT_EDOM; + } + return tgammaf(x); +#else + FIXME( "not implemented\n" ); + return 0.0f; +#endif +} + /********************************************************************* * nan (MSVCR120.@) */ diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index cde137d69ec..2a5fdf28934 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -2534,9 +2534,9 @@ @ cdecl tanh(double) MSVCRT_tanh @ cdecl -arch=arm,x86_64,arm64 tanhf(float) MSVCRT_tanhf @ cdecl terminate() MSVCRT_terminate -@ stub tgamma -@ stub tgammaf -@ stub tgammal +@ cdecl tgamma(double) MSVCR120_tgamma +@ cdecl tgammaf(float) MSVCR120_tgammaf +@ cdecl tgammal(double) MSVCR120_tgamma @ cdecl tmpfile() MSVCRT_tmpfile @ cdecl tmpfile_s(ptr) MSVCRT_tmpfile_s @ cdecl tmpnam(ptr) MSVCRT_tmpnam diff --git a/include/config.h.in b/include/config.h.in index ce5c1570541..29ea6f06636 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -1166,6 +1166,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H +/* Define to 1 if you have the `tgamma' function. */ +#undef HAVE_TGAMMA + +/* Define to 1 if you have the `tgammaf' function. */ +#undef HAVE_TGAMMAF + /* Define to 1 if you have the `thr_kill2' function. */ #undef HAVE_THR_KILL2