aboutsummaryrefslogtreecommitdiffstats
path: root/missing
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-12 16:12:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-12 16:12:46 +0000
commit6686b0b8d347fdec77f4b154d2362541a6e4e41f (patch)
tree9651cc4e0c45d2e48220c60342c4443b4c3349d0 /missing
parentd263f2d69b6e91dc4af232cf89e6bf0bf24c8d18 (diff)
downloadruby-6686b0b8d347fdec77f4b154d2362541a6e4e41f.tar.gz
fix tgamma for inifity
* configure.in: do not use buggy tgamma() of mingw. * missing/tgamma.c (tgamma): merge fix for inifity from ruby_tgamma. since msvcr120.dll and later have tgamma, this implementation will not be used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'missing')
-rw-r--r--missing/tgamma.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/missing/tgamma.c b/missing/tgamma.c
index 9324e19ea1..6260e4f519 100644
--- a/missing/tgamma.c
+++ b/missing/tgamma.c
@@ -10,9 +10,25 @@ reference - Haruhiko Okumura: C-gengo niyoru saishin algorithm jiten
gamma.c -- Gamma function
***********************************************************/
#include "ruby/config.h"
+#include "ruby/missing.h"
#include <math.h>
#include <errno.h>
+#ifdef _WIN32
+# include <float.h>
+# if !defined __MINGW32__ || defined __NO_ISOCEXT
+# ifndef isnan
+# define isnan(x) _isnan(x)
+# endif
+# ifndef isinf
+# define isinf(x) (!_finite(x) && !_isnan(x))
+# endif
+# ifndef finite
+# define finite(x) _finite(x)
+# endif
+# endif
+#endif
+
#ifndef HAVE_LGAMMA_R
#include <errno.h>
@@ -54,11 +70,16 @@ double tgamma(double x) /* Gamma function */
errno = ERANGE;
return 1/x < 0 ? -HUGE_VAL : HUGE_VAL;
}
+ if (isinf(x)) {
+ if (x < 0) goto domain_error;
+ return x;
+ }
if (x < 0) {
static double zero = 0.0;
double i, f;
f = modf(-x, &i);
if (f == 0.0) { /* Domain Error */
+ domain_error:
errno = EDOM;
return zero/zero;
}