[PATCHv2 3/4] msvcrt: Implement the tgamma functions

Martin Storsjo martin at martin.st
Thu Aug 1 14:52:26 CDT 2019


Signed-off-by: Martin Storsjo <martin at martin.st>
---
Now setting errno as it should, matching ucrt.
---
 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 +--
 6 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index a7c45ace73..086357be5e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2677,6 +2677,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 9eb3059b0d..736ffc6cc2 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 26d698317e..0204982533 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 3ca90c32ea..499beeae5f 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 c29539e0e2..7c8d273aa6 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -3380,6 +3380,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 6609683a4a..f1865c85ad 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
-- 
2.17.1




More information about the wine-devel mailing list