diff options
author | shirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-12 13:30:17 +0000 |
---|---|---|
committer | shirosaki <shirosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-12 13:30:17 +0000 |
commit | 8d236bc0b150b531acc121d657428bf824a9ca35 (patch) | |
tree | 0ef2b6a1fcaa7fbc5bc47b6d2a4de11c862b1373 /include | |
parent | 25a79e9f9be11f184485d3177a7ec75516d37259 (diff) |
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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include')
-rw-r--r-- | include/ruby/win32.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/ruby/win32.h b/include/ruby/win32.h index 718da1376c..a2eec0cf19 100644 --- a/include/ruby/win32.h +++ b/include/ruby/win32.h @@ -764,7 +764,7 @@ uintptr_t rb_w32_asynchronize(asynchronous_func_t func, uintptr_t self, int argc } /* 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 @@ rb_w32_pow(double x, double y) { 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 |