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

ruby-changes:25116

From: shirosaki <ko1@a...>
Date: Fri, 12 Oct 2012 22:30:26 +0900 (JST)
Subject: [ruby-changes:25116] shirosaki:r37168 (trunk): win32.h: set floating point precision for pow()

shirosaki	2012-10-12 22:30:17 +0900 (Fri, 12 Oct 2012)

  New Revision: 37168

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

  Log:
    win32.h: set floating point precision for pow()
    
    * include/ruby/win32.h (rb_w32_pow): set floating point precision
      for mingw-w64 x86 pow(). This improves the precision of pow() on
      Windows XP for TestFloat#test_round_with_precision failure.
      [ruby-core:47911] [Bug #7142]

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/win32.h

Index: include/ruby/win32.h
===================================================================
--- include/ruby/win32.h	(revision 37167)
+++ include/ruby/win32.h	(revision 37168)
@@ -764,7 +764,7 @@
 }  /* extern "C" { */
 #endif
 
-#ifdef __MINGW64__
+#if defined(__MINGW64__)
 /*
  * Use powl() instead of broken pow() of x86_64-w64-mingw32.
  * This workaround will fix test failures in test_bignum.rb,
@@ -775,6 +775,24 @@
 {
     return powl(x, y);
 }
+#elif defined(__MINGW64_VERSION_MAJOR)
+/*
+ * Set floating point precision for pow() of mingw-w64 x86.
+ * With default precision the result is not proper on WinXP.
+ */
+static inline double
+rb_w32_pow(double x, double y)
+{
+    double r;
+    unsigned int default_control = _controlfp(0, 0);
+    _controlfp(_PC_64, _MCW_PC);
+    r = pow(x, y);
+    /* Restore setting */
+    _controlfp(default_control, _MCW_PC);
+    return r;
+}
+#endif
+#if defined(__MINGW64_VERSION_MAJOR) || defined(__MINGW64__)
 #define pow rb_w32_pow
 #endif
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37167)
+++ ChangeLog	(revision 37168)
@@ -1,3 +1,10 @@
+Fri Oct 12 21:55:08 2012  Hiroshi Shirosaki  <h.shirosaki@g...>
+
+	* include/ruby/win32.h (rb_w32_pow): set floating point precision
+	  for mingw-w64 x86 pow(). This improves the precision of pow() on
+	  Windows XP for TestFloat#test_round_with_precision failure.
+	  [ruby-core:47911] [Bug #7142]
+
 Fri Oct 12 21:37:25 2012  Hiroshi Shirosaki  <h.shirosaki@g...>
 
 	* test/webrick/test_cgi.rb (TestWEBrickCGI#test_cgi): skip a test

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

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