]> granicus.if.org Git - python/commitdiff
#21167: Fix definition of NAN when ICC used without -fp-model strict.
authorR David Murray <rdmurray@bitdance.com>
Sat, 15 Aug 2015 22:33:45 +0000 (18:33 -0400)
committerR David Murray <rdmurray@bitdance.com>
Sat, 15 Aug 2015 22:33:45 +0000 (18:33 -0400)
Patch from Chris Hogan of Intel, reviewed by Mark Dickinson.

Include/pymath.h
Misc/ACKS
Misc/NEWS

index 62a6c42bbf0708bed968ada9e079dc449fd63dd0..1ea9ac1437a013196229eaa02acba9b7d069bd6a 100644 (file)
@@ -150,7 +150,29 @@ PyAPI_FUNC(void) _Py_set_387controlword(unsigned short);
  * doesn't support NaNs.
  */
 #if !defined(Py_NAN) && !defined(Py_NO_NAN)
-#define Py_NAN (Py_HUGE_VAL * 0.)
+#if !defined(__INTEL_COMPILER)
+    #define Py_NAN (Py_HUGE_VAL * 0.)
+#else /* __INTEL_COMPILER */
+    #if defined(ICC_NAN_STRICT)
+        #pragma float_control(push)
+        #pragma float_control(precise, on)
+        #pragma float_control(except,  on)
+        #if defined(_MSC_VER)
+            __declspec(noinline)
+        #else /* Linux */
+            __attribute__((noinline))
+        #endif /* _MSC_VER */
+        static double __icc_nan()
+        {
+            return sqrt(-1.0);
+        }
+        #pragma float_control (pop)
+        #define Py_NAN __icc_nan()
+    #else /* ICC_NAN_RELAXED as default for Intel Compiler */
+        static union { unsigned char buf[8]; double __icc_nan; } __nan_store = {0,0,0,0,0,0,0xf8,0x7f};
+        #define Py_NAN (__nan_store.__icc_nan)
+    #endif /* ICC_NAN_STRICT */
+#endif /* __INTEL_COMPILER */
 #endif
 
 /* Py_OVERFLOWED(X)
index e2e8387d95831dba031a584451082afcbc04025d..c2386e8107b2c0cc660d95e49b707944da812ab6 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -594,6 +594,7 @@ Gregor Hoffleit
 Chris Hoffman
 Stefan Hoffmeister
 Albert Hofkamp
+Chris Hogan
 Tomas Hoger
 Jonathan Hogg
 Kamilla Holanda
index 27a05648cc6f98a87b583c1634eaa333b6b348be..459bacc443b09da81071f89bac80789f671fc5c8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ Release date: 2015-08-23
 Core and Builtins
 -----------------
 
+- Issue #21167: NAN operations are now handled correctly when python is
+  compiled with ICC even if -fp-model strict is not specified.
+
 Library
 -------