[前][次][番号順一覧][スレッド一覧]

ruby-changes:42425

From: nobu <ko1@a...>
Date: Wed, 6 Apr 2016 13:16:52 +0900 (JST)
Subject: [ruby-changes:42425] nobu:r54499 (trunk): configure.in: check lgamma_r(-0.0)

nobu	2016-04-06 14:13:29 +0900 (Wed, 06 Apr 2016)

  New Revision: 54499

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54499

  Log:
    configure.in: check lgamma_r(-0.0)
    
    * configure.in (rb_cv_lgamma_r_m0): check if lgamma_r(-0.0)
      returns negative infinity.  [Bug #12249]
    * math.c (ruby_lgamma_r): define by the configured result.

  Modified files:
    trunk/ChangeLog
    trunk/configure.in
    trunk/math.c
Index: configure.in
===================================================================
--- configure.in	(revision 54498)
+++ configure.in	(revision 54499)
@@ -2498,6 +2498,38 @@ main(int argc, char **argv) https://github.com/ruby/ruby/blob/trunk/configure.in#L2498
 ])
 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_TRY_RUN([
+@%:@include <math.h>
+@%:@ifdef HAVE_UNISTD_H
+@%:@include <unistd.h>
+@%:@endif
+@%:@ifndef EXIT_SUCCESS
+@%:@define EXIT_SUCCESS 0
+@%:@endif
+@%:@ifndef EXIT_FAILURE
+@%:@define EXIT_FAILURE 1
+@%:@endif
+
+int
+main(int argc, char **argv)
+{
+    int sign;
+
+    if (lgamma_r(-0.0, &sign) >= 0) 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]
+	)
+    ])
+    AS_IF([test "x$rb_cv_lgamma_r_m0" = xno], [AC_DEFINE(LGAMMA_R_M0_FIX)])
+])
+
 # Some platform need -lrt for clock_gettime, but the other don't.
 if test x"$ac_cv_func_clock_gettime" != xyes; then
     # glibc 2.17 moves clock_* functions from librt to the main C library.
Index: math.c
===================================================================
--- math.c	(revision 54498)
+++ math.c	(revision 54499)
@@ -750,7 +750,7 @@ ruby_tgamma(const double d) https://github.com/ruby/ruby/blob/trunk/math.c#L750
 #define tgamma(d) ruby_tgamma(d)
 #endif
 
-#if defined __APPLE__
+#if defined LGAMMA_R_M0_FIX
 static inline double
 ruby_lgamma_r(const double d, int *sign)
 {
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54498)
+++ ChangeLog	(revision 54499)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Apr  6 14:13:28 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* configure.in (rb_cv_lgamma_r_m0): check if lgamma_r(-0.0)
+	  returns negative infinity.  [Bug #12249]
+
+	* math.c (ruby_lgamma_r): define by the configured result.
+
 Wed Apr  6 10:56:15 2016  Anton Davydov  <antondavydov.o@g...>
 
 	* lib/logger.rb (Logger#level=): remove unnecessary local

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]