platform/shared/ruby/missing/lgamma_r.c in rhodes-5.5.18 vs platform/shared/ruby/missing/lgamma_r.c in rhodes-6.0.11

- old
+ new

@@ -6,10 +6,11 @@ (New Algorithm handbook in C language) (Gijyutsu hyouron sha, Tokyo, 1991) [in Japanese] http://oku.edu.mie-u.ac.jp/~okumura/algo/ */ +#include "ruby/missing.h" /*********************************************************** gamma.c -- Gamma function ***********************************************************/ #include <math.h> #include <errno.h> @@ -44,18 +45,29 @@ + (B8 / ( 8 * 7))) * w + (B6 / ( 6 * 5))) * w + (B4 / ( 4 * 3))) * w + (B2 / ( 2 * 1))) / x + 0.5 * LOG_2PI - log(v) - x + (x - 0.5) * log(x); } + +#ifdef __MINGW_ATTRIB_PURE +/* get rid of bugs in math.h of mingw */ +#define modf(_X, _Y) __extension__ ({\ + double intpart_modf_bug = intpart_modf_bug;\ + double result_modf_bug = modf((_X), &intpart_modf_bug);\ + *(_Y) = intpart_modf_bug;\ + result_modf_bug;\ +}) +#endif + /* the natural logarithm of the absolute value of the Gamma function */ double lgamma_r(double x, int *signp) { if (x <= 0) { double i, f, s; f = modf(-x, &i); if (f == 0.0) { /* pole error */ - *signp = 1; + *signp = signbit(x) ? -1 : 1; errno = ERANGE; return HUGE_VAL; } *signp = (fmod(i, 2.0) != 0.0) ? 1 : -1; s = sin(PI * f);