summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-05-04 13:30:43 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-05-04 13:30:43 (GMT)
commite05e8409e1b47a2c018ad8a67016546217165c60 (patch)
treec9c456bdf14ee3d9c0821ee2ee843a45bcf9bdf9 /Include
parent67032252588e3919e4fbfbbd256b91add8a5af45 (diff)
downloadcpython-e05e8409e1b47a2c018ad8a67016546217165c60.zip
cpython-e05e8409e1b47a2c018ad8a67016546217165c60.tar.gz
cpython-e05e8409e1b47a2c018ad8a67016546217165c60.tar.bz2
Issue #5724: Fix cmath failures on Solaris 10.
Diffstat (limited to 'Include')
-rw-r--r--Include/pymath.h35
1 files changed, 28 insertions, 7 deletions
diff --git a/Include/pymath.h b/Include/pymath.h
index 7cea9ae..6ad174d 100644
--- a/Include/pymath.h
+++ b/Include/pymath.h
@@ -77,6 +77,21 @@ extern double copysign(double, double);
#define Py_MATH_E 2.7182818284590452354
#endif
+/* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU
+ register and into a 64-bit memory location, rounding from extended
+ precision to double precision in the process. On other platforms it does
+ nothing. */
+
+/* we take double rounding as evidence of x87 usage */
+#ifndef Py_FORCE_DOUBLE
+# ifdef X87_DOUBLE_ROUNDING
+PyAPI_FUNC(double) _Py_force_double(double);
+# define Py_FORCE_DOUBLE(X) (_Py_force_double(X))
+# else
+# define Py_FORCE_DOUBLE(X) (X)
+# endif
+#endif
+
/* Py_IS_NAN(X)
* Return 1 if float or double arg is a NaN, else 0.
* Caution:
@@ -87,7 +102,7 @@ extern double copysign(double, double);
* Note: PC/pyconfig.h defines Py_IS_NAN as _isnan
*/
#ifndef Py_IS_NAN
-#ifdef HAVE_ISNAN
+#if defined HAVE_DECL_ISNAN && HAVE_DECL_ISNAN == 1
#define Py_IS_NAN(X) isnan(X)
#else
#define Py_IS_NAN(X) ((X) != (X))
@@ -101,14 +116,18 @@ extern double copysign(double, double);
* This implementation may set the underflow flag if |X| is very small;
* it really can't be implemented correctly (& easily) before C99.
* Override in pyconfig.h if you have a better spelling on your platform.
+ * Py_FORCE_DOUBLE is used to avoid getting false negatives from a
+ * non-infinite value v sitting in an 80-bit x87 register such that
+ * v becomes infinite when spilled from the register to 64-bit memory.
* Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf
*/
#ifndef Py_IS_INFINITY
-#ifdef HAVE_ISINF
-#define Py_IS_INFINITY(X) isinf(X)
-#else
-#define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X))
-#endif
+# if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1
+# define Py_IS_INFINITY(X) isinf(X)
+# else
+# define Py_IS_INFINITY(X) ((X) && \
+ (Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X)))
+# endif
#endif
/* Py_IS_FINITE(X)
@@ -118,7 +137,9 @@ extern double copysign(double, double);
* Note: PC/pyconfig.h defines Py_IS_FINITE as _finite
*/
#ifndef Py_IS_FINITE
-#ifdef HAVE_FINITE
+#if defined HAVE_DECL_ISFINITE && HAVE_DECL_ISFINITE == 1
+#define Py_IS_FINITE(X) isfinite(X)
+#elif defined HAVE_FINITE
#define Py_IS_FINITE(X) finite(X)
#else
#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X))