summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2015-08-13 13:58:07 (GMT)
committerR David Murray <rdmurray@bitdance.com>2015-08-13 13:58:07 (GMT)
commitedbc28ce81f46d042f9d5ddf9c5bc8cecebc715a (patch)
tree9cbc21722e0c22f7e6909a502f34a99d6c5612e1 /Include
parent9632ea2f26831ae3bbf41ca570d6e138c2f13656 (diff)
downloadcpython-edbc28ce81f46d042f9d5ddf9c5bc8cecebc715a.zip
cpython-edbc28ce81f46d042f9d5ddf9c5bc8cecebc715a.tar.gz
cpython-edbc28ce81f46d042f9d5ddf9c5bc8cecebc715a.tar.bz2
#21167: Fix definition of NAN when ICC used without -fp-model strict.
Patch from Chris Hogan of Intel, reviewed by Mark Dickinson.
Diffstat (limited to 'Include')
-rw-r--r--Include/pymath.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/Include/pymath.h b/Include/pymath.h
index 62a6c42..1ea9ac1 100644
--- a/Include/pymath.h
+++ b/Include/pymath.h
@@ -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)