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

ruby-changes:33849

From: nobu <ko1@a...>
Date: Mon, 12 May 2014 23:57:23 +0900 (JST)
Subject: [ruby-changes:33849] nobu:r45930 (trunk): configure.in: check atan2

nobu	2014-05-12 23:57:17 +0900 (Mon, 12 May 2014)

  New Revision: 45930

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45930

  Log:
    configure.in: check atan2
    
    * configure.in (rb_cv_atan2_inf_c99): check whether runtime atan2
      handles Inf as C99.  ruby-core:62536] [Bug #9831]

  Modified files:
    trunk/ChangeLog
    trunk/configure.in
    trunk/math.c
Index: math.c
===================================================================
--- math.c	(revision 45929)
+++ math.c	(revision 45930)
@@ -79,8 +79,7 @@ math_atan2(VALUE obj, VALUE y, VALUE x) https://github.com/ruby/ruby/blob/trunk/math.c#L79
 	    return DBL2NUM(M_PI);
 	return DBL2NUM(-M_PI);
     }
-#if !(defined(HAVE_ATAN2L) && defined(HAVE_ATAN2F))
-    /* assume atan2() doesn't handle Inf as C99 */
+#ifndef ATAN2_INF_C99
     if (isinf(dx) && isinf(dy)) {
 	/* optimization for FLONUM */
 	if (dx < 0.0) {
Index: configure.in
===================================================================
--- configure.in	(revision 45929)
+++ configure.in	(revision 45930)
@@ -2145,6 +2145,35 @@ void qsort_r(void *base, size_t nmemb, s https://github.com/ruby/ruby/blob/trunk/configure.in#L2145
   ])
 fi
 
+AC_CACHE_CHECK(whether atan2 handles Inf as C99, rb_cv_atan2_inf_c99, [
+    AS_IF([test $ac_cv_func_atan2f:$ac_cv_func_atan2l = yes:yes], [
+	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)
+{
+    if (fabs(atan2(INFINITY, INFINITY) - M_PI_4) <= 0.01) return EXIT_SUCCESS;
+    return EXIT_FAILURE;
+}
+],
+	[rb_cv_atan2_inf_c99=yes],
+	[rb_cv_atan2_inf_c99=no],
+	[AS_CASE($target_os, [mingw*|mswin*], [rb_cv_atan2_inf_c99=no], [rb_cv_atan2_inf_c99=yes])]
+	)
+    ])
+])
+AS_IF([test $rb_cv_atan2_inf_c99 = yes], [AC_DEFINE(ATAN2_INF_C99)])
+
 # 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: ChangeLog
===================================================================
--- ChangeLog	(revision 45929)
+++ ChangeLog	(revision 45930)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon May 12 23:57:15 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* configure.in (rb_cv_atan2_inf_c99): check whether runtime atan2
+	  handles Inf as C99.  ruby-core:62536] [Bug #9831]
+
 Mon May 12 20:33:01 2014  Tanaka Akira  <akr@f...>
 
 	* configure.in: Invoke AC_REPLACE_FUNCS for each function.

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

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