Merged revisions 69459 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r69459 | mark.dickinson | 2009-02-09 14:18:43 +0000 (Mon, 09 Feb 2009) | 3 lines Issue #4575: fix Py_IS_INFINITY macro to work correctly on x87 FPUs. It now forces its argument to double before testing for infinity. ........
This commit is contained in:
parent
ae09899fa3
commit
87ec0855c6
|
@ -77,6 +77,21 @@ extern double copysign(double, double);
|
||||||
#define Py_MATH_E 2.7182818284590452354
|
#define Py_MATH_E 2.7182818284590452354
|
||||||
#endif
|
#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)
|
/* Py_IS_NAN(X)
|
||||||
* Return 1 if float or double arg is a NaN, else 0.
|
* Return 1 if float or double arg is a NaN, else 0.
|
||||||
* Caution:
|
* Caution:
|
||||||
|
@ -101,14 +116,18 @@ extern double copysign(double, double);
|
||||||
* This implementation may set the underflow flag if |X| is very small;
|
* This implementation may set the underflow flag if |X| is very small;
|
||||||
* it really can't be implemented correctly (& easily) before C99.
|
* it really can't be implemented correctly (& easily) before C99.
|
||||||
* Override in pyconfig.h if you have a better spelling on your platform.
|
* 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
|
* Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf
|
||||||
*/
|
*/
|
||||||
#ifndef Py_IS_INFINITY
|
#ifndef Py_IS_INFINITY
|
||||||
#if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1
|
# if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1
|
||||||
#define Py_IS_INFINITY(X) isinf(X)
|
# define Py_IS_INFINITY(X) isinf(X)
|
||||||
#else
|
# else
|
||||||
#define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X))
|
# define Py_IS_INFINITY(X) ((X) && \
|
||||||
#endif
|
(Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X)))
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Py_IS_FINITE(X)
|
/* Py_IS_FINITE(X)
|
||||||
|
|
|
@ -12,6 +12,9 @@ What's New in Python 3.1 alpha 0
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #4575: Fix Py_IS_INFINITY macro to work correctly on x87 FPUs:
|
||||||
|
it now forces its argument to double before testing for infinity.
|
||||||
|
|
||||||
- Issue #5137: Make len() correctly raise a TypeError when a __len__ method
|
- Issue #5137: Make len() correctly raise a TypeError when a __len__ method
|
||||||
returns a non-number type.
|
returns a non-number type.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,18 @@
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
|
||||||
|
#ifdef X87_DOUBLE_ROUNDING
|
||||||
|
/* On x86 platforms using an x87 FPU, this function is called from the
|
||||||
|
Py_FORCE_DOUBLE macro (defined in pymath.h) to force a floating-point
|
||||||
|
number out of an 80-bit x87 FPU register and into a 64-bit memory location,
|
||||||
|
thus rounding from extended precision to double precision. */
|
||||||
|
double _Py_force_double(double x)
|
||||||
|
{
|
||||||
|
volatile double y;
|
||||||
|
y = x;
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_HYPOT
|
#ifndef HAVE_HYPOT
|
||||||
double hypot(double x, double y)
|
double hypot(double x, double y)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue