Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r49043:40d990865485
Date: 2011-11-09 19:20 +0100
http://bitbucket.org/pypy/pypy/changeset/40d990865485/

Log:    Fix? the Windows build by using the Windows functions _isnan() and
        _finite() if we are *not* jitted.

diff --git a/pypy/rpython/lltypesystem/module/ll_math.py 
b/pypy/rpython/lltypesystem/module/ll_math.py
--- a/pypy/rpython/lltypesystem/module/ll_math.py
+++ b/pypy/rpython/lltypesystem/module/ll_math.py
@@ -11,15 +11,17 @@
 from pypy.translator.platform import platform
 from pypy.rlib.rfloat import isfinite, isinf, isnan, INFINITY, NAN
 
+use_library_isinf_isnan = False
 if sys.platform == "win32":
     if platform.name == "msvc":
         # When compiled with /O2 or /Oi (enable intrinsic functions)
         # It's no more possible to take the address of some math functions.
         # Ensure that the compiler chooses real functions instead.
         eci = ExternalCompilationInfo(
-            includes = ['math.h'],
+            includes = ['math.h', 'float.h'],
             post_include_bits = ['#pragma function(floor)'],
             )
+        use_library_isinf_isnan = True
     else:
         eci = ExternalCompilationInfo()
     # Some math functions are C99 and not defined by the Microsoft compiler
@@ -112,17 +114,28 @@
 while VERY_LARGE_FLOAT * 100.0 != INFINITY:
     VERY_LARGE_FLOAT *= 64.0
 
+_lib_isnan = rffi.llexternal("_isnan", [lltype.Float], lltype.Signed,
+                             compilation_info=eci)
+_lib_finite = rffi.llexternal("_finite", [lltype.Float], lltype.Signed,
+                             compilation_info=eci)
+
 def ll_math_isnan(y):
     # By not calling into the external function the JIT can inline this.
     # Floats are awesome.
+    if use_library_isinf_isnan and not jit.we_are_jitted():
+        return _lib_isnan(y)
     return y != y
 
 def ll_math_isinf(y):
+    if use_library_isinf_isnan and not jit.we_are_jitted():
+        return not _lib_finite(y) and not _lib_isnan(y)
     return (y + VERY_LARGE_FLOAT) == y
 
 def ll_math_isfinite(y):
     # Use a custom hack that is reasonably well-suited to the JIT.
     # Floats are awesome (bis).
+    if use_library_isinf_isnan and not jit.we_are_jitted():
+        return _lib_finite(y)
     z = 0.0 * y
     return z == z       # i.e.: z is not a NaN
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to