From 542d3a071f0cf5fd7488edcb11ab0472990e9bbf Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 5 Apr 2016 15:53:32 +0000 Subject: math.c: fix lgamma * math.c (ruby_lgamma_r): fix lgamma(-0.0) on mingw and OSX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- math.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'math.c') diff --git a/math.c b/math.c index e1dfe975d2..9e97f3a2d2 100644 --- a/math.c +++ b/math.c @@ -750,6 +750,22 @@ ruby_tgamma(const double d) #define tgamma(d) ruby_tgamma(d) #endif +#if defined __MINGW32__ || defined __APPLE__ +static inline double +ruby_lgamma_r(const double d, int *sign) +{ + const double g = lgamma_r(d, sign); + if (isinf(g)) { + if (d == 0.0 && signbit(d)) { + *sign = -1; + return INFINITY; + } + } + return g; +} +#define lgamma_r(d, sign) ruby_lgamma_r(d, sign) +#endif + /* * call-seq: * Math.gamma(x) -> Float -- cgit v1.2.1