mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* configure.in (rb_cv_lgamma_r_pm0): check if lgamma_r(+0.0)
returns positive infinity, in addition to lgamma_r(-0.0). AIX returns an incorrect result of negative infinity. * math.c (ruby_lgamma_r): handle +0.0, in addition to -0.0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
173005bb6f
commit
7a3f794da0
3 changed files with 24 additions and 7 deletions
|
@ -1,3 +1,11 @@
|
|||
Thu Apr 28 04:49:07 2016 Rei Odaira <Rei.Odaira@gmail.com>
|
||||
|
||||
* configure.in (rb_cv_lgamma_r_pm0): check if lgamma_r(+0.0)
|
||||
returns positive infinity, in addition to lgamma_r(-0.0).
|
||||
AIX returns an incorrect result of negative infinity.
|
||||
|
||||
* math.c (ruby_lgamma_r): handle +0.0, in addition to -0.0.
|
||||
|
||||
Thu Apr 28 01:11:14 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* time.c: define _DEFAULT_SOURCE because glibc 2.20 depracates
|
||||
|
|
18
configure.in
18
configure.in
|
@ -2503,7 +2503,7 @@ main(int argc, char **argv)
|
|||
AS_IF([test "x$rb_cv_atan2_inf_c99" = xyes], [AC_DEFINE(ATAN2_INF_C99)])
|
||||
|
||||
AS_IF([test "x$ac_cv_func_lgamma_r" = xyes], [
|
||||
AC_CACHE_CHECK(whether lgamma_r handles -0.0, rb_cv_lgamma_r_m0, [
|
||||
AC_CACHE_CHECK(whether lgamma_r handles +0.0 and -0.0, rb_cv_lgamma_r_pm0, [
|
||||
AC_TRY_RUN([
|
||||
@%:@include <math.h>
|
||||
@%:@ifdef HAVE_UNISTD_H
|
||||
|
@ -2519,22 +2519,28 @@ AS_IF([test "x$ac_cv_func_lgamma_r" = xyes], [
|
|||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int sign;
|
||||
int sign = 0;
|
||||
double x = lgamma_r(-0.0, &sign);
|
||||
|
||||
/* should be [+inf, -1] */
|
||||
if (x <= 0) return EXIT_FAILURE;
|
||||
if (!isinf(x)) return EXIT_FAILURE;
|
||||
if (sign != -1) return EXIT_FAILURE;
|
||||
|
||||
/* should be [+inf, 1] */
|
||||
x = lgamma_r(+0.0, &sign);
|
||||
if (x <= 0) return EXIT_FAILURE;
|
||||
if (!isinf(x)) return EXIT_FAILURE;
|
||||
if (sign != 1) return EXIT_FAILURE;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
],
|
||||
[rb_cv_lgamma_r_m0=yes],
|
||||
[rb_cv_lgamma_r_m0=no],
|
||||
[rb_cv_lgamma_r_m0=yes]
|
||||
[rb_cv_lgamma_r_pm0=yes],
|
||||
[rb_cv_lgamma_r_pm0=no],
|
||||
[rb_cv_lgamma_r_pm0=yes]
|
||||
)
|
||||
])
|
||||
AS_IF([test "x$rb_cv_lgamma_r_m0" = xno], [AC_DEFINE(LGAMMA_R_M0_FIX)])
|
||||
AS_IF([test "x$rb_cv_lgamma_r_pm0" = xno], [AC_DEFINE(LGAMMA_R_PM0_FIX)])
|
||||
])
|
||||
|
||||
# Some platform need -lrt for clock_gettime, but the other don't.
|
||||
|
|
5
math.c
5
math.c
|
@ -750,7 +750,7 @@ ruby_tgamma(const double d)
|
|||
#define tgamma(d) ruby_tgamma(d)
|
||||
#endif
|
||||
|
||||
#if defined LGAMMA_R_M0_FIX
|
||||
#if defined LGAMMA_R_PM0_FIX
|
||||
static inline double
|
||||
ruby_lgamma_r(const double d, int *sign)
|
||||
{
|
||||
|
@ -759,6 +759,9 @@ ruby_lgamma_r(const double d, int *sign)
|
|||
if (d == 0.0 && signbit(d)) {
|
||||
*sign = -1;
|
||||
return INFINITY;
|
||||
} else if (d == 0.0 && !signbit(d)) {
|
||||
*sign = 1;
|
||||
return INFINITY;
|
||||
}
|
||||
}
|
||||
return g;
|
||||
|
|
Loading…
Reference in a new issue