Issue #1580: use short float repr where possible.
- incorporate and adapt David Gay's dtoa and strtod into the Python core - on platforms where we can use Gay's code (almost all!), repr(float) is based on the shortest sequence of decimal digits that rounds correctly. - add sys.float_repr_style attribute to indicate whether we're using Gay's code or not - add autoconf magic to detect and enable SSE2 instructions on x86/gcc - slight change to repr and str: repr switches to exponential notation at 1e16 instead of 1e17, str switches at 1e11 instead of 1e12
This commit is contained in:
parent
579b65c2d6
commit
b08a53a99d
|
@ -266,6 +266,19 @@ always available.
|
||||||
The information in the table is simplified.
|
The information in the table is simplified.
|
||||||
|
|
||||||
|
|
||||||
|
.. data:: float_repr_style
|
||||||
|
|
||||||
|
A string indicating how the :func:`repr` function behaves for
|
||||||
|
floats. If the string has value ``'short'`` then for a finite
|
||||||
|
float ``x``, ``repr(x)`` aims to produce a short string with the
|
||||||
|
property that ``float(repr(x)) == x``. This is the usual behaviour
|
||||||
|
in Python 3.1 and later. Otherwise, ``float_repr_style`` has value
|
||||||
|
``'legacy'`` and ``repr(x)`` behaves in the same way as it did in
|
||||||
|
versions of Python prior to 3.1.
|
||||||
|
|
||||||
|
.. versionadded:: 3.1
|
||||||
|
|
||||||
|
|
||||||
.. function:: getcheckinterval()
|
.. function:: getcheckinterval()
|
||||||
|
|
||||||
Return the interpreter's "check interval"; see :func:`setcheckinterval`.
|
Return the interpreter's "check interval"; see :func:`setcheckinterval`.
|
||||||
|
|
|
@ -657,3 +657,35 @@ The :mod:`select` and contains the following notice for the kqueue interface::
|
||||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
SUCH DAMAGE.
|
SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
strtod and dtoa
|
||||||
|
---------------
|
||||||
|
|
||||||
|
The file :file:`Python/dtoa.c`, which supplies C functions dtoa and
|
||||||
|
strtod for conversion of C doubles to and from strings, is derived
|
||||||
|
from the file of the same name by David M. Gay, currently available
|
||||||
|
from http://www.netlib.org/fp/. The original file, as retrieved on
|
||||||
|
March 16, 2009, contains the following copyright and licensing
|
||||||
|
notice::
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
*
|
||||||
|
* The author of this software is David M. Gay.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose without fee is hereby granted, provided that this entire notice
|
||||||
|
* is included in all copies of any software which is or includes a copy
|
||||||
|
* or modification of this software and in all copies of the supporting
|
||||||
|
* documentation for such software.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
|
||||||
|
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
|
||||||
|
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
***************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,7 @@
|
||||||
|
|
||||||
#include "pystrtod.h"
|
#include "pystrtod.h"
|
||||||
#include "pystrcmp.h"
|
#include "pystrcmp.h"
|
||||||
|
#include "dtoa.h"
|
||||||
|
|
||||||
/* _Py_Mangle is defined in compile.c */
|
/* _Py_Mangle is defined in compile.c */
|
||||||
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
|
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef PY_NO_SHORT_FLOAT_REPR
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
|
||||||
|
PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
|
||||||
|
int *decpt, int *sign, char **rve);
|
||||||
|
PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -17,6 +17,9 @@
|
||||||
# undef SIZEOF_VOID_P
|
# undef SIZEOF_VOID_P
|
||||||
# undef SIZEOF__BOOL
|
# undef SIZEOF__BOOL
|
||||||
# undef WORDS_BIGENDIAN
|
# undef WORDS_BIGENDIAN
|
||||||
|
# undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754
|
||||||
|
# undef DOUBLE_IS_BIG_ENDIAN_IEEE754
|
||||||
|
# undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754
|
||||||
|
|
||||||
# undef VA_LIST_IS_ARRAY
|
# undef VA_LIST_IS_ARRAY
|
||||||
# if defined(__LP64__) && defined(__x86_64__)
|
# if defined(__LP64__) && defined(__x86_64__)
|
||||||
|
@ -65,6 +68,9 @@
|
||||||
|
|
||||||
#ifdef __BIG_ENDIAN__
|
#ifdef __BIG_ENDIAN__
|
||||||
#define WORDS_BIGENDIAN 1
|
#define WORDS_BIGENDIAN 1
|
||||||
|
#define DOUBLE_IS_BIG_ENDIAN_IEEE754
|
||||||
|
#else
|
||||||
|
#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754
|
||||||
#endif /* __BIG_ENDIAN */
|
#endif /* __BIG_ENDIAN */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,11 @@ PyAPI_FUNC(double) _Py_force_double(double);
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_GCC_ASM_FOR_X87
|
||||||
|
PyAPI_FUNC(unsigned short) _Py_get_387controlword(void);
|
||||||
|
PyAPI_FUNC(void) _Py_set_387controlword(unsigned short);
|
||||||
|
#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:
|
||||||
|
|
|
@ -465,6 +465,53 @@ extern "C" {
|
||||||
errno = 0; \
|
errno = 0; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
/* The functions _Py_dg_strtod and _Py_dg_dtoa in Python/dtoa.c require that
|
||||||
|
the FPU is using 53-bit precision. Here are macros that force this. See
|
||||||
|
Python/pystrtod.c for an example of their use. */
|
||||||
|
|
||||||
|
#ifdef USING_X87_FPU
|
||||||
|
#define _Py_SET_53BIT_PRECISION_HEADER \
|
||||||
|
unsigned short old_387controlword, new_387controlword
|
||||||
|
#define _Py_SET_53BIT_PRECISION_START \
|
||||||
|
do { \
|
||||||
|
old_387controlword = _Py_get_387controlword(); \
|
||||||
|
new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \
|
||||||
|
if (new_387controlword != old_387controlword) \
|
||||||
|
_Py_set_387controlword(new_387controlword); \
|
||||||
|
} while (0)
|
||||||
|
#define _Py_SET_53BIT_PRECISION_END \
|
||||||
|
if (new_387controlword != old_387controlword) \
|
||||||
|
_Py_set_387controlword(old_387controlword)
|
||||||
|
#else
|
||||||
|
#define _Py_SET_53BIT_PRECISION_HEADER
|
||||||
|
#define _Py_SET_53BIT_PRECISION_START
|
||||||
|
#define _Py_SET_53BIT_PRECISION_END
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If we can't guarantee 53-bit precision, don't use the code
|
||||||
|
in Python/dtoa.c, but fall back to standard code. This
|
||||||
|
means that repr of a float will be long (17 sig digits).
|
||||||
|
|
||||||
|
Realistically, there are two things that could go wrong:
|
||||||
|
|
||||||
|
(1) doubles aren't IEEE 754 doubles, or
|
||||||
|
(2) we're on x86 with the rounding precision set to 64-bits
|
||||||
|
(extended precision), and we don't know how to change
|
||||||
|
the rounding precision.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \
|
||||||
|
!defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \
|
||||||
|
!defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754)
|
||||||
|
#define PY_NO_SHORT_FLOAT_REPR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* double rounding is symptomatic of use of extended precision on x86 */
|
||||||
|
#ifdef X87_DOUBLE_ROUNDING
|
||||||
|
#define PY_NO_SHORT_FLOAT_REPR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Py_DEPRECATED(version)
|
/* Py_DEPRECATED(version)
|
||||||
* Declare a variable, type, or function deprecated.
|
* Declare a variable, type, or function deprecated.
|
||||||
* Usage:
|
* Usage:
|
||||||
|
|
|
@ -0,0 +1,354 @@
|
||||||
|
-- 'f' code formatting, with explicit precision (>= 0). Output always
|
||||||
|
-- has the given number of places after the point; zeros are added if
|
||||||
|
-- necessary to make this true.
|
||||||
|
|
||||||
|
-- zeros
|
||||||
|
%.0f 0 -> 0
|
||||||
|
%.1f 0 -> 0.0
|
||||||
|
%.2f 0 -> 0.00
|
||||||
|
%.3f 0 -> 0.000
|
||||||
|
%.50f 0 -> 0.00000000000000000000000000000000000000000000000000
|
||||||
|
|
||||||
|
-- precision 0; result should never include a .
|
||||||
|
%.0f 1.5 -> 2
|
||||||
|
%.0f 2.5 -> 2
|
||||||
|
%.0f 3.5 -> 4
|
||||||
|
%.0f 0.0 -> 0
|
||||||
|
%.0f 0.1 -> 0
|
||||||
|
%.0f 0.001 -> 0
|
||||||
|
%.0f 10.0 -> 10
|
||||||
|
%.0f 10.1 -> 10
|
||||||
|
%.0f 10.01 -> 10
|
||||||
|
%.0f 123.456 -> 123
|
||||||
|
%.0f 1234.56 -> 1235
|
||||||
|
%.0f 1e49 -> 9999999999999999464902769475481793196872414789632
|
||||||
|
-- %.0f 1e50 -> 100000000000000007629769841091887003294964970946560
|
||||||
|
%.0f 9.9999999999999987e+49 -> 99999999999999986860582406952576489172979654066176
|
||||||
|
|
||||||
|
-- precision 1
|
||||||
|
%.1f 0.0001 -> 0.0
|
||||||
|
%.1f 0.001 -> 0.0
|
||||||
|
%.1f 0.01 -> 0.0
|
||||||
|
%.1f 0.04 -> 0.0
|
||||||
|
%.1f 0.06 -> 0.1
|
||||||
|
%.1f 0.25 -> 0.2
|
||||||
|
%.1f 0.75 -> 0.8
|
||||||
|
%.1f 1.4 -> 1.4
|
||||||
|
%.1f 1.5 -> 1.5
|
||||||
|
%.1f 10.0 -> 10.0
|
||||||
|
%.1f 1000.03 -> 1000.0
|
||||||
|
%.1f 1234.5678 -> 1234.6
|
||||||
|
%.1f 1234.7499 -> 1234.7
|
||||||
|
%.1f 1234.75 -> 1234.8
|
||||||
|
|
||||||
|
-- precision 2
|
||||||
|
%.2f 0.0001 -> 0.00
|
||||||
|
%.2f 0.001 -> 0.00
|
||||||
|
%.2f 0.004999 -> 0.00
|
||||||
|
%.2f 0.005001 -> 0.01
|
||||||
|
%.2f 0.01 -> 0.01
|
||||||
|
%.2f 0.125 -> 0.12
|
||||||
|
%.2f 0.375 -> 0.38
|
||||||
|
%.2f 1234500 -> 1234500.00
|
||||||
|
%.2f 1234560 -> 1234560.00
|
||||||
|
%.2f 1234567 -> 1234567.00
|
||||||
|
%.2f 1234567.8 -> 1234567.80
|
||||||
|
%.2f 1234567.89 -> 1234567.89
|
||||||
|
%.2f 1234567.891 -> 1234567.89
|
||||||
|
%.2f 1234567.8912 -> 1234567.89
|
||||||
|
|
||||||
|
-- alternate form always includes a decimal point. This only
|
||||||
|
-- makes a difference when the precision is 0.
|
||||||
|
%#.0f 0 -> 0.
|
||||||
|
%#.1f 0 -> 0.0
|
||||||
|
%#.0f 1.5 -> 2.
|
||||||
|
%#.0f 2.5 -> 2.
|
||||||
|
%#.0f 10.1 -> 10.
|
||||||
|
%#.0f 1234.56 -> 1235.
|
||||||
|
%#.1f 1.4 -> 1.4
|
||||||
|
%#.2f 0.375 -> 0.38
|
||||||
|
|
||||||
|
-- if precision is omitted it defaults to 6
|
||||||
|
%f 0 -> 0.000000
|
||||||
|
%f 1230000 -> 1230000.000000
|
||||||
|
%f 1234567 -> 1234567.000000
|
||||||
|
%f 123.4567 -> 123.456700
|
||||||
|
%f 1.23456789 -> 1.234568
|
||||||
|
%f 0.00012 -> 0.000120
|
||||||
|
%f 0.000123 -> 0.000123
|
||||||
|
%f 0.00012345 -> 0.000123
|
||||||
|
%f 0.000001 -> 0.000001
|
||||||
|
%f 0.0000005001 -> 0.000001
|
||||||
|
%f 0.0000004999 -> 0.000000
|
||||||
|
|
||||||
|
-- 'e' code formatting with explicit precision (>= 0). Output should
|
||||||
|
-- always have exactly the number of places after the point that were
|
||||||
|
-- requested.
|
||||||
|
|
||||||
|
-- zeros
|
||||||
|
%.0e 0 -> 0e+00
|
||||||
|
%.1e 0 -> 0.0e+00
|
||||||
|
%.2e 0 -> 0.00e+00
|
||||||
|
%.10e 0 -> 0.0000000000e+00
|
||||||
|
%.50e 0 -> 0.00000000000000000000000000000000000000000000000000e+00
|
||||||
|
|
||||||
|
-- precision 0. no decimal point in the output
|
||||||
|
%.0e 0.01 -> 1e-02
|
||||||
|
%.0e 0.1 -> 1e-01
|
||||||
|
%.0e 1 -> 1e+00
|
||||||
|
%.0e 10 -> 1e+01
|
||||||
|
%.0e 100 -> 1e+02
|
||||||
|
%.0e 0.012 -> 1e-02
|
||||||
|
%.0e 0.12 -> 1e-01
|
||||||
|
%.0e 1.2 -> 1e+00
|
||||||
|
%.0e 12 -> 1e+01
|
||||||
|
%.0e 120 -> 1e+02
|
||||||
|
%.0e 123.456 -> 1e+02
|
||||||
|
%.0e 0.000123456 -> 1e-04
|
||||||
|
%.0e 123456000 -> 1e+08
|
||||||
|
%.0e 0.5 -> 5e-01
|
||||||
|
%.0e 1.4 -> 1e+00
|
||||||
|
%.0e 1.5 -> 2e+00
|
||||||
|
%.0e 1.6 -> 2e+00
|
||||||
|
%.0e 2.4999999 -> 2e+00
|
||||||
|
%.0e 2.5 -> 2e+00
|
||||||
|
%.0e 2.5000001 -> 3e+00
|
||||||
|
%.0e 3.499999999999 -> 3e+00
|
||||||
|
%.0e 3.5 -> 4e+00
|
||||||
|
%.0e 4.5 -> 4e+00
|
||||||
|
%.0e 5.5 -> 6e+00
|
||||||
|
%.0e 6.5 -> 6e+00
|
||||||
|
%.0e 7.5 -> 8e+00
|
||||||
|
%.0e 8.5 -> 8e+00
|
||||||
|
%.0e 9.4999 -> 9e+00
|
||||||
|
%.0e 9.5 -> 1e+01
|
||||||
|
%.0e 10.5 -> 1e+01
|
||||||
|
%.0e 14.999 -> 1e+01
|
||||||
|
%.0e 15 -> 2e+01
|
||||||
|
|
||||||
|
-- precision 1
|
||||||
|
%.1e 0.0001 -> 1.0e-04
|
||||||
|
%.1e 0.001 -> 1.0e-03
|
||||||
|
%.1e 0.01 -> 1.0e-02
|
||||||
|
%.1e 0.1 -> 1.0e-01
|
||||||
|
%.1e 1 -> 1.0e+00
|
||||||
|
%.1e 10 -> 1.0e+01
|
||||||
|
%.1e 100 -> 1.0e+02
|
||||||
|
%.1e 120 -> 1.2e+02
|
||||||
|
%.1e 123 -> 1.2e+02
|
||||||
|
%.1e 123.4 -> 1.2e+02
|
||||||
|
|
||||||
|
-- precision 2
|
||||||
|
%.2e 0.00013 -> 1.30e-04
|
||||||
|
%.2e 0.000135 -> 1.35e-04
|
||||||
|
%.2e 0.0001357 -> 1.36e-04
|
||||||
|
%.2e 0.0001 -> 1.00e-04
|
||||||
|
%.2e 0.001 -> 1.00e-03
|
||||||
|
%.2e 0.01 -> 1.00e-02
|
||||||
|
%.2e 0.1 -> 1.00e-01
|
||||||
|
%.2e 1 -> 1.00e+00
|
||||||
|
%.2e 10 -> 1.00e+01
|
||||||
|
%.2e 100 -> 1.00e+02
|
||||||
|
%.2e 1000 -> 1.00e+03
|
||||||
|
%.2e 1500 -> 1.50e+03
|
||||||
|
%.2e 1590 -> 1.59e+03
|
||||||
|
%.2e 1598 -> 1.60e+03
|
||||||
|
%.2e 1598.7 -> 1.60e+03
|
||||||
|
%.2e 1598.76 -> 1.60e+03
|
||||||
|
%.2e 9999 -> 1.00e+04
|
||||||
|
|
||||||
|
-- omitted precision defaults to 6
|
||||||
|
%e 0 -> 0.000000e+00
|
||||||
|
%e 165 -> 1.650000e+02
|
||||||
|
%e 1234567 -> 1.234567e+06
|
||||||
|
%e 12345678 -> 1.234568e+07
|
||||||
|
%e 1.1 -> 1.100000e+00
|
||||||
|
|
||||||
|
-- alternate form always contains a decimal point. This only makes
|
||||||
|
-- a difference when precision is 0.
|
||||||
|
|
||||||
|
%#.0e 0.01 -> 1.e-02
|
||||||
|
%#.0e 0.1 -> 1.e-01
|
||||||
|
%#.0e 1 -> 1.e+00
|
||||||
|
%#.0e 10 -> 1.e+01
|
||||||
|
%#.0e 100 -> 1.e+02
|
||||||
|
%#.0e 0.012 -> 1.e-02
|
||||||
|
%#.0e 0.12 -> 1.e-01
|
||||||
|
%#.0e 1.2 -> 1.e+00
|
||||||
|
%#.0e 12 -> 1.e+01
|
||||||
|
%#.0e 120 -> 1.e+02
|
||||||
|
%#.0e 123.456 -> 1.e+02
|
||||||
|
%#.0e 0.000123456 -> 1.e-04
|
||||||
|
%#.0e 123456000 -> 1.e+08
|
||||||
|
%#.0e 0.5 -> 5.e-01
|
||||||
|
%#.0e 1.4 -> 1.e+00
|
||||||
|
%#.0e 1.5 -> 2.e+00
|
||||||
|
%#.0e 1.6 -> 2.e+00
|
||||||
|
%#.0e 2.4999999 -> 2.e+00
|
||||||
|
%#.0e 2.5 -> 2.e+00
|
||||||
|
%#.0e 2.5000001 -> 3.e+00
|
||||||
|
%#.0e 3.499999999999 -> 3.e+00
|
||||||
|
%#.0e 3.5 -> 4.e+00
|
||||||
|
%#.0e 4.5 -> 4.e+00
|
||||||
|
%#.0e 5.5 -> 6.e+00
|
||||||
|
%#.0e 6.5 -> 6.e+00
|
||||||
|
%#.0e 7.5 -> 8.e+00
|
||||||
|
%#.0e 8.5 -> 8.e+00
|
||||||
|
%#.0e 9.4999 -> 9.e+00
|
||||||
|
%#.0e 9.5 -> 1.e+01
|
||||||
|
%#.0e 10.5 -> 1.e+01
|
||||||
|
%#.0e 14.999 -> 1.e+01
|
||||||
|
%#.0e 15 -> 2.e+01
|
||||||
|
%#.1e 123.4 -> 1.2e+02
|
||||||
|
%#.2e 0.0001357 -> 1.36e-04
|
||||||
|
|
||||||
|
-- 'g' code formatting.
|
||||||
|
|
||||||
|
-- zeros
|
||||||
|
%.0g 0 -> 0
|
||||||
|
%.1g 0 -> 0
|
||||||
|
%.2g 0 -> 0
|
||||||
|
%.3g 0 -> 0
|
||||||
|
%.4g 0 -> 0
|
||||||
|
%.10g 0 -> 0
|
||||||
|
%.50g 0 -> 0
|
||||||
|
%.100g 0 -> 0
|
||||||
|
|
||||||
|
-- precision 0 doesn't make a lot of sense for the 'g' code (what does
|
||||||
|
-- it mean to have no significant digits?); in practice, it's interpreted
|
||||||
|
-- as identical to precision 1
|
||||||
|
%.0g 1000 -> 1e+03
|
||||||
|
%.0g 100 -> 1e+02
|
||||||
|
%.0g 10 -> 1e+01
|
||||||
|
%.0g 1 -> 1
|
||||||
|
%.0g 0.1 -> 0.1
|
||||||
|
%.0g 0.01 -> 0.01
|
||||||
|
%.0g 1e-3 -> 0.001
|
||||||
|
%.0g 1e-4 -> 0.0001
|
||||||
|
%.0g 1e-5 -> 1e-05
|
||||||
|
%.0g 1e-6 -> 1e-06
|
||||||
|
%.0g 12 -> 1e+01
|
||||||
|
%.0g 120 -> 1e+02
|
||||||
|
%.0g 1.2 -> 1
|
||||||
|
%.0g 0.12 -> 0.1
|
||||||
|
%.0g 0.012 -> 0.01
|
||||||
|
%.0g 0.0012 -> 0.001
|
||||||
|
%.0g 0.00012 -> 0.0001
|
||||||
|
%.0g 0.000012 -> 1e-05
|
||||||
|
%.0g 0.0000012 -> 1e-06
|
||||||
|
|
||||||
|
-- precision 1 identical to precision 0
|
||||||
|
%.1g 1000 -> 1e+03
|
||||||
|
%.1g 100 -> 1e+02
|
||||||
|
%.1g 10 -> 1e+01
|
||||||
|
%.1g 1 -> 1
|
||||||
|
%.1g 0.1 -> 0.1
|
||||||
|
%.1g 0.01 -> 0.01
|
||||||
|
%.1g 1e-3 -> 0.001
|
||||||
|
%.1g 1e-4 -> 0.0001
|
||||||
|
%.1g 1e-5 -> 1e-05
|
||||||
|
%.1g 1e-6 -> 1e-06
|
||||||
|
%.1g 12 -> 1e+01
|
||||||
|
%.1g 120 -> 1e+02
|
||||||
|
%.1g 1.2 -> 1
|
||||||
|
%.1g 0.12 -> 0.1
|
||||||
|
%.1g 0.012 -> 0.01
|
||||||
|
%.1g 0.0012 -> 0.001
|
||||||
|
%.1g 0.00012 -> 0.0001
|
||||||
|
%.1g 0.000012 -> 1e-05
|
||||||
|
%.1g 0.0000012 -> 1e-06
|
||||||
|
|
||||||
|
-- precision 2
|
||||||
|
%.2g 1000 -> 1e+03
|
||||||
|
%.2g 100 -> 1e+02
|
||||||
|
%.2g 10 -> 10
|
||||||
|
%.2g 1 -> 1
|
||||||
|
%.2g 0.1 -> 0.1
|
||||||
|
%.2g 0.01 -> 0.01
|
||||||
|
%.2g 0.001 -> 0.001
|
||||||
|
%.2g 1e-4 -> 0.0001
|
||||||
|
%.2g 1e-5 -> 1e-05
|
||||||
|
%.2g 1e-6 -> 1e-06
|
||||||
|
%.2g 1234 -> 1.2e+03
|
||||||
|
%.2g 123 -> 1.2e+02
|
||||||
|
%.2g 12.3 -> 12
|
||||||
|
%.2g 1.23 -> 1.2
|
||||||
|
%.2g 0.123 -> 0.12
|
||||||
|
%.2g 0.0123 -> 0.012
|
||||||
|
%.2g 0.00123 -> 0.0012
|
||||||
|
%.2g 0.000123 -> 0.00012
|
||||||
|
%.2g 0.0000123 -> 1.2e-05
|
||||||
|
|
||||||
|
-- alternate g formatting: always include decimal point and
|
||||||
|
-- exactly <precision> significant digits.
|
||||||
|
%#.0g 0 -> 0.
|
||||||
|
%#.1g 0 -> 0.
|
||||||
|
%#.2g 0 -> 0.0
|
||||||
|
%#.3g 0 -> 0.00
|
||||||
|
%#.4g 0 -> 0.000
|
||||||
|
|
||||||
|
%#.0g 0.2 -> 0.2
|
||||||
|
%#.1g 0.2 -> 0.2
|
||||||
|
%#.2g 0.2 -> 0.20
|
||||||
|
%#.3g 0.2 -> 0.200
|
||||||
|
%#.4g 0.2 -> 0.2000
|
||||||
|
%#.10g 0.2 -> 0.2000000000
|
||||||
|
|
||||||
|
%#.0g 2 -> 2.
|
||||||
|
%#.1g 2 -> 2.
|
||||||
|
%#.2g 2 -> 2.0
|
||||||
|
%#.3g 2 -> 2.00
|
||||||
|
%#.4g 2 -> 2.000
|
||||||
|
|
||||||
|
%#.0g 20 -> 2.e+01
|
||||||
|
%#.1g 20 -> 2.e+01
|
||||||
|
%#.2g 20 -> 20.
|
||||||
|
%#.3g 20 -> 20.0
|
||||||
|
%#.4g 20 -> 20.00
|
||||||
|
|
||||||
|
%#.0g 234.56 -> 2.e+02
|
||||||
|
%#.1g 234.56 -> 2.e+02
|
||||||
|
%#.2g 234.56 -> 2.3e+02
|
||||||
|
%#.3g 234.56 -> 235.
|
||||||
|
%#.4g 234.56 -> 234.6
|
||||||
|
%#.5g 234.56 -> 234.56
|
||||||
|
%#.6g 234.56 -> 234.560
|
||||||
|
|
||||||
|
-- for repr formatting see the separate test_short_repr test in
|
||||||
|
-- test_float.py. Not all platforms use short repr for floats.
|
||||||
|
|
||||||
|
-- str formatting. Result always includes decimal point and at
|
||||||
|
-- least one digit after the point, or an exponent.
|
||||||
|
%s 0 -> 0.0
|
||||||
|
%s 1 -> 1.0
|
||||||
|
|
||||||
|
%s 0.01 -> 0.01
|
||||||
|
%s 0.02 -> 0.02
|
||||||
|
%s 0.03 -> 0.03
|
||||||
|
%s 0.04 -> 0.04
|
||||||
|
%s 0.05 -> 0.05
|
||||||
|
|
||||||
|
-- str truncates to 12 significant digits
|
||||||
|
%s 1.234123412341 -> 1.23412341234
|
||||||
|
%s 1.23412341234 -> 1.23412341234
|
||||||
|
%s 1.2341234123 -> 1.2341234123
|
||||||
|
|
||||||
|
-- values >= 1e11 get an exponent
|
||||||
|
%s 10 -> 10.0
|
||||||
|
%s 100 -> 100.0
|
||||||
|
%s 1e10 -> 10000000000.0
|
||||||
|
%s 9.999e10 -> 99990000000.0
|
||||||
|
%s 99999999999 -> 99999999999.0
|
||||||
|
%s 1e11 -> 1e+11
|
||||||
|
%s 1e12 -> 1e+12
|
||||||
|
|
||||||
|
-- as do values < 1e-4
|
||||||
|
%s 1e-3 -> 0.001
|
||||||
|
%s 1.001e-4 -> 0.0001001
|
||||||
|
%s 1.000000000001e-4 -> 0.0001
|
||||||
|
%s 1.00000000001e-4 -> 0.000100000000001
|
||||||
|
%s 1.0000000001e-4 -> 0.00010000000001
|
||||||
|
%s 1e-4 -> 0.0001
|
||||||
|
%s 0.999999999999e-4 -> 9.99999999999e-05
|
||||||
|
%s 0.999e-4 -> 9.99e-05
|
||||||
|
%s 1e-5 -> 1e-05
|
|
@ -305,6 +305,7 @@ PYTHON_OBJS= \
|
||||||
Python/getopt.o \
|
Python/getopt.o \
|
||||||
Python/pystrcmp.o \
|
Python/pystrcmp.o \
|
||||||
Python/pystrtod.o \
|
Python/pystrtod.o \
|
||||||
|
Python/dtoa.o \
|
||||||
Python/formatter_unicode.o \
|
Python/formatter_unicode.o \
|
||||||
Python/$(DYNLOADFILE) \
|
Python/$(DYNLOADFILE) \
|
||||||
$(LIBOBJS) \
|
$(LIBOBJS) \
|
||||||
|
@ -621,6 +622,7 @@ PYTHON_HEADERS= \
|
||||||
Include/complexobject.h \
|
Include/complexobject.h \
|
||||||
Include/descrobject.h \
|
Include/descrobject.h \
|
||||||
Include/dictobject.h \
|
Include/dictobject.h \
|
||||||
|
Include/dtoa.h \
|
||||||
Include/enumobject.h \
|
Include/enumobject.h \
|
||||||
Include/errcode.h \
|
Include/errcode.h \
|
||||||
Include/eval.h \
|
Include/eval.h \
|
||||||
|
|
|
@ -160,6 +160,7 @@ Scott David Daniels
|
||||||
Ben Darnell
|
Ben Darnell
|
||||||
Jonathan Dasteel
|
Jonathan Dasteel
|
||||||
John DeGood
|
John DeGood
|
||||||
|
Ned Deily
|
||||||
Vincent Delft
|
Vincent Delft
|
||||||
Arnaud Delobelle
|
Arnaud Delobelle
|
||||||
Erik Demaine
|
Erik Demaine
|
||||||
|
|
39
Misc/NEWS
39
Misc/NEWS
|
@ -12,6 +12,45 @@ What's New in Python 3.1 beta 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- The repr function switches to exponential notation at 1e16, not 1e17
|
||||||
|
as it did before. This change applies to both 'short' and legacy
|
||||||
|
float repr styles. For the new repr style, it avoids misleading
|
||||||
|
output in some cases: an example is repr(2e16+8), which gives
|
||||||
|
'2.000000000000001e+16'; without this change it would have produced
|
||||||
|
'20000000000000010.0' instead.
|
||||||
|
|
||||||
|
- Similarly, the str function switches to exponential notation at
|
||||||
|
1e11, not 1e12. This avoids printing 13 significant digits in
|
||||||
|
situations where only 12 of them are correct. Example problem
|
||||||
|
value: str(1e11 + 0.5). (This minor issue has existed in 2.x for a
|
||||||
|
long time.)
|
||||||
|
|
||||||
|
- On x86, SSE2 instructions for floating-point are automatically
|
||||||
|
detected and, where possible, enabled on platforms using the gcc
|
||||||
|
compiler. As a consequence, some arithmetic operations may have
|
||||||
|
different (more accurate!) results on some platforms, and
|
||||||
|
cross-platform consistency of Python arithmetic should be improved.
|
||||||
|
This applies particularly to Linux/x86.
|
||||||
|
|
||||||
|
- Issue #1580: On most platforms, use a 'short' float repr: for a
|
||||||
|
finite float x, repr(x) now outputs a string based on the shortest
|
||||||
|
sequence of decimal digits that rounds to x. Previous behaviour was
|
||||||
|
to output 17 significant digits and then strip trailing zeros.
|
||||||
|
|
||||||
|
There's a new sys attribute sys.float_repr_style, which takes
|
||||||
|
the value 'short' to indicate that we're using short float repr,
|
||||||
|
and 'legacy' if the short float repr isn't available for one
|
||||||
|
reason or another.
|
||||||
|
|
||||||
|
The float repr change involves incorporating David Gay's 'perfect
|
||||||
|
rounding' code into the Python core (it's in Python/dtoa.c). As a
|
||||||
|
secondary consequence, all string-to-float and float-to-string
|
||||||
|
conversions (including all float formatting operations) will be
|
||||||
|
correctly rounded on these platforms.
|
||||||
|
|
||||||
|
See issue 1580 discussions for details of platforms for which
|
||||||
|
this change does not apply.
|
||||||
|
|
||||||
- Issue #5759: float() didn't call __float__ on str subclasses.
|
- Issue #5759: float() didn't call __float__ on str subclasses.
|
||||||
|
|
||||||
- The string.maketrans() function is deprecated; there is a new static method
|
- The string.maketrans() function is deprecated; there is a new static method
|
||||||
|
|
|
@ -752,4 +752,8 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
|
||||||
socket handles greater than FD_SETSIZE */
|
socket handles greater than FD_SETSIZE */
|
||||||
#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
|
#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
|
||||||
|
|
||||||
|
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the
|
||||||
|
least significant byte first */
|
||||||
|
#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1
|
||||||
|
|
||||||
#endif /* !Py_CONFIG_H */
|
#endif /* !Py_CONFIG_H */
|
||||||
|
|
|
@ -894,6 +894,10 @@
|
||||||
RelativePath="..\Include\pystrtod.h"
|
RelativePath="..\Include\pystrtod.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\Include\dtoa.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\Include\Python-ast.h"
|
RelativePath="..\Include\Python-ast.h"
|
||||||
>
|
>
|
||||||
|
@ -1746,6 +1750,10 @@
|
||||||
RelativePath="..\Python\pystrtod.c"
|
RelativePath="..\Python\pystrtod.c"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\Python\dtoa.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\Python\Python-ast.c"
|
RelativePath="..\Python\Python-ast.c"
|
||||||
>
|
>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,6 +13,28 @@ double _Py_force_double(double x)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USING_X87_FPU
|
||||||
|
# ifdef HAVE_GCC_ASM_FOR_X87
|
||||||
|
|
||||||
|
/* inline assembly for getting and setting the 387 FPU control word on
|
||||||
|
gcc/x86 */
|
||||||
|
|
||||||
|
unsigned short _Py_get_387controlword(void) {
|
||||||
|
unsigned short cw;
|
||||||
|
__asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
|
||||||
|
return cw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _Py_set_387controlword(unsigned short cw) {
|
||||||
|
__asm__ __volatile__ ("fldcw %0" : : "m" (cw));
|
||||||
|
}
|
||||||
|
|
||||||
|
# else
|
||||||
|
# error "Unable to get and set x87 control word"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef HAVE_HYPOT
|
#ifndef HAVE_HYPOT
|
||||||
double hypot(double x, double y)
|
double hypot(double x, double y)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1025,6 +1025,7 @@ platform -- platform identifier\n\
|
||||||
executable -- pathname of this Python interpreter\n\
|
executable -- pathname of this Python interpreter\n\
|
||||||
prefix -- prefix used to find the Python library\n\
|
prefix -- prefix used to find the Python library\n\
|
||||||
exec_prefix -- prefix used to find the machine-specific Python library\n\
|
exec_prefix -- prefix used to find the machine-specific Python library\n\
|
||||||
|
float_repr_style -- string indicating the style of repr() output for floats\n\
|
||||||
"
|
"
|
||||||
)
|
)
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
|
@ -1428,6 +1429,15 @@ _PySys_Init(void)
|
||||||
FlagsType.tp_init = NULL;
|
FlagsType.tp_init = NULL;
|
||||||
FlagsType.tp_new = NULL;
|
FlagsType.tp_new = NULL;
|
||||||
|
|
||||||
|
/* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
|
||||||
|
#ifndef PY_NO_SHORT_FLOAT_REPR
|
||||||
|
SET_SYS_FROM_STRING("float_repr_style",
|
||||||
|
PyUnicode_FromString("short"));
|
||||||
|
#else
|
||||||
|
SET_SYS_FROM_STRING("float_repr_style",
|
||||||
|
PyUnicode_FromString("legacy"));
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef SET_SYS_FROM_STRING
|
#undef SET_SYS_FROM_STRING
|
||||||
if (PyErr_Occurred())
|
if (PyErr_Occurred())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# From configure.in Revision: 71261 .
|
# From configure.in Revision: 71274 .
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.61 for python 3.1.
|
# Generated by GNU Autoconf 2.61 for python 3.1.
|
||||||
#
|
#
|
||||||
|
@ -21603,12 +21603,455 @@ echo "${ECHO_T}default LIBC=\"$LIBC\"" >&6; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ************************************
|
# **************************************************
|
||||||
# * Check for mathematical functions *
|
# * Check for various properties of floating point *
|
||||||
# ************************************
|
# **************************************************
|
||||||
|
|
||||||
LIBS_SAVE=$LIBS
|
{ echo "$as_me:$LINENO: checking whether C doubles are little-endian IEEE 754 binary64" >&5
|
||||||
LIBS="$LIBS $LIBM"
|
echo $ECHO_N "checking whether C doubles are little-endian IEEE 754 binary64... $ECHO_C" >&6; }
|
||||||
|
if test "${ac_cv_little_endian_double+set}" = set; then
|
||||||
|
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||||
|
else
|
||||||
|
|
||||||
|
if test "$cross_compiling" = yes; then
|
||||||
|
ac_cv_little_endian_double=no
|
||||||
|
else
|
||||||
|
cat >conftest.$ac_ext <<_ACEOF
|
||||||
|
/* confdefs.h. */
|
||||||
|
_ACEOF
|
||||||
|
cat confdefs.h >>conftest.$ac_ext
|
||||||
|
cat >>conftest.$ac_ext <<_ACEOF
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
int main() {
|
||||||
|
double x = 9006104071832581.0;
|
||||||
|
if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ACEOF
|
||||||
|
rm -f conftest$ac_exeext
|
||||||
|
if { (ac_try="$ac_link"
|
||||||
|
case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_link") 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
|
||||||
|
{ (case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_try") 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; }; then
|
||||||
|
ac_cv_little_endian_double=yes
|
||||||
|
else
|
||||||
|
echo "$as_me: program exited with status $ac_status" >&5
|
||||||
|
echo "$as_me: failed program was:" >&5
|
||||||
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
|
||||||
|
( exit $ac_status )
|
||||||
|
ac_cv_little_endian_double=no
|
||||||
|
fi
|
||||||
|
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
{ echo "$as_me:$LINENO: result: $ac_cv_little_endian_double" >&5
|
||||||
|
echo "${ECHO_T}$ac_cv_little_endian_double" >&6; }
|
||||||
|
if test "$ac_cv_little_endian_double" = yes
|
||||||
|
then
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
{ echo "$as_me:$LINENO: checking whether C doubles are big-endian IEEE 754 binary64" >&5
|
||||||
|
echo $ECHO_N "checking whether C doubles are big-endian IEEE 754 binary64... $ECHO_C" >&6; }
|
||||||
|
if test "${ac_cv_big_endian_double+set}" = set; then
|
||||||
|
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||||
|
else
|
||||||
|
|
||||||
|
if test "$cross_compiling" = yes; then
|
||||||
|
ac_cv_big_endian_double=no
|
||||||
|
else
|
||||||
|
cat >conftest.$ac_ext <<_ACEOF
|
||||||
|
/* confdefs.h. */
|
||||||
|
_ACEOF
|
||||||
|
cat confdefs.h >>conftest.$ac_ext
|
||||||
|
cat >>conftest.$ac_ext <<_ACEOF
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
int main() {
|
||||||
|
double x = 9006104071832581.0;
|
||||||
|
if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ACEOF
|
||||||
|
rm -f conftest$ac_exeext
|
||||||
|
if { (ac_try="$ac_link"
|
||||||
|
case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_link") 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
|
||||||
|
{ (case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_try") 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; }; then
|
||||||
|
ac_cv_big_endian_double=yes
|
||||||
|
else
|
||||||
|
echo "$as_me: program exited with status $ac_status" >&5
|
||||||
|
echo "$as_me: failed program was:" >&5
|
||||||
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
|
||||||
|
( exit $ac_status )
|
||||||
|
ac_cv_big_endian_double=no
|
||||||
|
fi
|
||||||
|
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
{ echo "$as_me:$LINENO: result: $ac_cv_big_endian_double" >&5
|
||||||
|
echo "${ECHO_T}$ac_cv_big_endian_double" >&6; }
|
||||||
|
if test "$ac_cv_big_endian_double" = yes
|
||||||
|
then
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define DOUBLE_IS_BIG_ENDIAN_IEEE754 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Some ARM platforms use a mixed-endian representation for doubles.
|
||||||
|
# While Python doesn't currently have full support for these platforms
|
||||||
|
# (see e.g., issue 1762561), we can at least make sure that float <-> string
|
||||||
|
# conversions work.
|
||||||
|
{ echo "$as_me:$LINENO: checking whether C doubles are ARM mixed-endian IEEE 754 binary64" >&5
|
||||||
|
echo $ECHO_N "checking whether C doubles are ARM mixed-endian IEEE 754 binary64... $ECHO_C" >&6; }
|
||||||
|
if test "${ac_cv_mixed_endian_double+set}" = set; then
|
||||||
|
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||||
|
else
|
||||||
|
|
||||||
|
if test "$cross_compiling" = yes; then
|
||||||
|
ac_cv_mixed_endian_double=no
|
||||||
|
else
|
||||||
|
cat >conftest.$ac_ext <<_ACEOF
|
||||||
|
/* confdefs.h. */
|
||||||
|
_ACEOF
|
||||||
|
cat confdefs.h >>conftest.$ac_ext
|
||||||
|
cat >>conftest.$ac_ext <<_ACEOF
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
int main() {
|
||||||
|
double x = 9006104071832581.0;
|
||||||
|
if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ACEOF
|
||||||
|
rm -f conftest$ac_exeext
|
||||||
|
if { (ac_try="$ac_link"
|
||||||
|
case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_link") 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
|
||||||
|
{ (case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_try") 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; }; then
|
||||||
|
ac_cv_mixed_endian_double=yes
|
||||||
|
else
|
||||||
|
echo "$as_me: program exited with status $ac_status" >&5
|
||||||
|
echo "$as_me: failed program was:" >&5
|
||||||
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
|
||||||
|
( exit $ac_status )
|
||||||
|
ac_cv_mixed_endian_double=no
|
||||||
|
fi
|
||||||
|
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
{ echo "$as_me:$LINENO: result: $ac_cv_mixed_endian_double" >&5
|
||||||
|
echo "${ECHO_T}$ac_cv_mixed_endian_double" >&6; }
|
||||||
|
if test "$ac_cv_mixed_endian_double" = yes
|
||||||
|
then
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# David Gay's code in Python/dtoa.c requires that the FPU uses 53-bit
|
||||||
|
# rounding; this is a particular problem on x86, where the x87 FPU has
|
||||||
|
# a default rounding precision of 64 bits. For gcc/x86, we try to fix
|
||||||
|
# this by:
|
||||||
|
#
|
||||||
|
# (1) using the SSE2 instruction set when available (it usually is
|
||||||
|
# on modern machines)
|
||||||
|
# (2) using inline assembler to get and set the x87 FPU control word
|
||||||
|
# otherwise.
|
||||||
|
#
|
||||||
|
# On AMD64 (aka x86-64), gcc automatically enables use of SSE2
|
||||||
|
# instructions, so we don't bother trying to detect.
|
||||||
|
|
||||||
|
if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
|
||||||
|
then
|
||||||
|
# determine whether we're already using the SSE2 instruction set for math
|
||||||
|
# (e.g., this is true by default on OS X/x86)
|
||||||
|
{ echo "$as_me:$LINENO: checking whether SSE2 instructions are already enabled for math" >&5
|
||||||
|
echo $ECHO_N "checking whether SSE2 instructions are already enabled for math... $ECHO_C" >&6; }
|
||||||
|
if test -n "`$CC -dM -E - </dev/null | grep __SSE2_MATH__`"
|
||||||
|
then
|
||||||
|
ac_sse2_enabled=yes
|
||||||
|
else
|
||||||
|
ac_sse2_enabled=no
|
||||||
|
fi
|
||||||
|
{ echo "$as_me:$LINENO: result: $ac_sse2_enabled" >&5
|
||||||
|
echo "${ECHO_T}$ac_sse2_enabled" >&6; }
|
||||||
|
|
||||||
|
# if we're not using SSE2 already, we need to either enable it
|
||||||
|
# (when available), or use inline assembler to get and set the
|
||||||
|
# 387 control word.
|
||||||
|
if test $ac_sse2_enabled = no
|
||||||
|
then
|
||||||
|
# Check cpuid for SSE2 availability. Bits 25 and 26 of edx tell
|
||||||
|
# us about SSE and SSE2 respectively.
|
||||||
|
{ echo "$as_me:$LINENO: checking whether SSE2 instructions are available on this CPU" >&5
|
||||||
|
echo $ECHO_N "checking whether SSE2 instructions are available on this CPU... $ECHO_C" >&6; }
|
||||||
|
if test "$cross_compiling" = yes; then
|
||||||
|
ac_cv_cpu_has_sse2=no
|
||||||
|
else
|
||||||
|
cat >conftest.$ac_ext <<_ACEOF
|
||||||
|
/* confdefs.h. */
|
||||||
|
_ACEOF
|
||||||
|
cat confdefs.h >>conftest.$ac_ext
|
||||||
|
cat >>conftest.$ac_ext <<_ACEOF
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
unsigned int ax, bx, cx, dx, func;
|
||||||
|
func = 1U;
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"pushl %%ebx\n\t" /* don't clobber ebx */
|
||||||
|
"cpuid\n\t"
|
||||||
|
"movl %%ebx, %1\n\t"
|
||||||
|
"popl %%ebx"
|
||||||
|
: "=a" (ax), "=r" (bx), "=c" (cx), "=d" (dx)
|
||||||
|
: "a" (func)
|
||||||
|
: "cc" );
|
||||||
|
if ((dx & (1U << 25)) && (dx & (1U << 26)))
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ACEOF
|
||||||
|
rm -f conftest$ac_exeext
|
||||||
|
if { (ac_try="$ac_link"
|
||||||
|
case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_link") 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
|
||||||
|
{ (case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_try") 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; }; then
|
||||||
|
ac_cv_cpu_has_sse2=yes
|
||||||
|
else
|
||||||
|
echo "$as_me: program exited with status $ac_status" >&5
|
||||||
|
echo "$as_me: failed program was:" >&5
|
||||||
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
|
||||||
|
( exit $ac_status )
|
||||||
|
ac_cv_cpu_has_sse2=no
|
||||||
|
fi
|
||||||
|
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
{ echo "$as_me:$LINENO: result: $ac_cv_cpu_has_sse2" >&5
|
||||||
|
echo "${ECHO_T}$ac_cv_cpu_has_sse2" >&6; }
|
||||||
|
|
||||||
|
# determine whether gcc accepts options to turn on SSE2
|
||||||
|
{ echo "$as_me:$LINENO: checking whether $CC accepts -msse2 -mfpmath=sse" >&5
|
||||||
|
echo $ECHO_N "checking whether $CC accepts -msse2 -mfpmath=sse... $ECHO_C" >&6; }
|
||||||
|
ac_save_cc="$CC"
|
||||||
|
CC="$CC -msse2 -mfpmath=sse"
|
||||||
|
if test "$cross_compiling" = yes; then
|
||||||
|
ac_cv_msse2_ok=no
|
||||||
|
else
|
||||||
|
cat >conftest.$ac_ext <<_ACEOF
|
||||||
|
/* confdefs.h. */
|
||||||
|
_ACEOF
|
||||||
|
cat confdefs.h >>conftest.$ac_ext
|
||||||
|
cat >>conftest.$ac_ext <<_ACEOF
|
||||||
|
/* end confdefs.h. */
|
||||||
|
int main() { return 0; }
|
||||||
|
_ACEOF
|
||||||
|
rm -f conftest$ac_exeext
|
||||||
|
if { (ac_try="$ac_link"
|
||||||
|
case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_link") 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
|
||||||
|
{ (case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_try") 2>&5
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); }; }; then
|
||||||
|
ac_cv_msse2_ok=yes
|
||||||
|
else
|
||||||
|
echo "$as_me: program exited with status $ac_status" >&5
|
||||||
|
echo "$as_me: failed program was:" >&5
|
||||||
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
|
||||||
|
( exit $ac_status )
|
||||||
|
ac_cv_msse2_ok=no
|
||||||
|
fi
|
||||||
|
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
CC="$ac_save_cc"
|
||||||
|
{ echo "$as_me:$LINENO: result: $ac_cv_msse2_ok" >&5
|
||||||
|
echo "${ECHO_T}$ac_cv_msse2_ok" >&6; }
|
||||||
|
|
||||||
|
if test $ac_cv_cpu_has_sse2 = yes && test $ac_cv_msse2_ok = yes
|
||||||
|
then
|
||||||
|
BASECFLAGS="$BASECFLAGS -msse2 -mfpmath=sse"
|
||||||
|
else
|
||||||
|
# SSE2 doesn't appear to be available. Check that it's okay
|
||||||
|
# to use gcc inline assembler to get and set x87 control word
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define USING_X87_FPU 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
{ echo "$as_me:$LINENO: checking whether we can use gcc inline assembler to get and set x87 control word" >&5
|
||||||
|
echo $ECHO_N "checking whether we can use gcc inline assembler to get and set x87 control word... $ECHO_C" >&6; }
|
||||||
|
cat >conftest.$ac_ext <<_ACEOF
|
||||||
|
/* confdefs.h. */
|
||||||
|
_ACEOF
|
||||||
|
cat confdefs.h >>conftest.$ac_ext
|
||||||
|
cat >>conftest.$ac_ext <<_ACEOF
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
unsigned short cw;
|
||||||
|
__asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
|
||||||
|
__asm__ __volatile__ ("fldcw %0" : : "m" (cw));
|
||||||
|
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
rm -f conftest.$ac_objext
|
||||||
|
if { (ac_try="$ac_compile"
|
||||||
|
case "(($ac_try" in
|
||||||
|
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||||
|
*) ac_try_echo=$ac_try;;
|
||||||
|
esac
|
||||||
|
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||||
|
(eval "$ac_compile") 2>conftest.er1
|
||||||
|
ac_status=$?
|
||||||
|
grep -v '^ *+' conftest.er1 >conftest.err
|
||||||
|
rm -f conftest.er1
|
||||||
|
cat conftest.err >&5
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||||
|
(exit $ac_status); } && {
|
||||||
|
test -z "$ac_c_werror_flag" ||
|
||||||
|
test ! -s conftest.err
|
||||||
|
} && test -s conftest.$ac_objext; then
|
||||||
|
have_gcc_asm_for_x87=yes
|
||||||
|
else
|
||||||
|
echo "$as_me: failed program was:" >&5
|
||||||
|
sed 's/^/| /' conftest.$ac_ext >&5
|
||||||
|
|
||||||
|
have_gcc_asm_for_x87=no
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||||
|
{ echo "$as_me:$LINENO: result: $have_gcc_asm_for_x87" >&5
|
||||||
|
echo "${ECHO_T}$have_gcc_asm_for_x87" >&6; }
|
||||||
|
if test "$have_gcc_asm_for_x87" = yes
|
||||||
|
then
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define HAVE_GCC_ASM_FOR_X87 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Detect whether system arithmetic is subject to x87-style double
|
# Detect whether system arithmetic is subject to x87-style double
|
||||||
# rounding issues. The result of this test has little meaning on non
|
# rounding issues. The result of this test has little meaning on non
|
||||||
|
@ -21617,10 +22060,9 @@ LIBS="$LIBS $LIBM"
|
||||||
# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
|
# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
|
||||||
{ echo "$as_me:$LINENO: checking for x87-style double rounding" >&5
|
{ echo "$as_me:$LINENO: checking for x87-style double rounding" >&5
|
||||||
echo $ECHO_N "checking for x87-style double rounding... $ECHO_C" >&6; }
|
echo $ECHO_N "checking for x87-style double rounding... $ECHO_C" >&6; }
|
||||||
if test "${ac_cv_x87_double_rounding+set}" = set; then
|
# $BASECFLAGS may affect the result
|
||||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
ac_save_cc="$CC"
|
||||||
else
|
CC="$CC $BASECFLAGS"
|
||||||
|
|
||||||
if test "$cross_compiling" = yes; then
|
if test "$cross_compiling" = yes; then
|
||||||
ac_cv_x87_double_rounding=no
|
ac_cv_x87_double_rounding=no
|
||||||
else
|
else
|
||||||
|
@ -21684,8 +22126,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$a
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
fi
|
CC="$ac_save_cc"
|
||||||
|
|
||||||
{ echo "$as_me:$LINENO: result: $ac_cv_x87_double_rounding" >&5
|
{ echo "$as_me:$LINENO: result: $ac_cv_x87_double_rounding" >&5
|
||||||
echo "${ECHO_T}$ac_cv_x87_double_rounding" >&6; }
|
echo "${ECHO_T}$ac_cv_x87_double_rounding" >&6; }
|
||||||
if test "$ac_cv_x87_double_rounding" = yes
|
if test "$ac_cv_x87_double_rounding" = yes
|
||||||
|
@ -21697,6 +22138,13 @@ _ACEOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ************************************
|
||||||
|
# * Check for mathematical functions *
|
||||||
|
# ************************************
|
||||||
|
|
||||||
|
LIBS_SAVE=$LIBS
|
||||||
|
LIBS="$LIBS $LIBM"
|
||||||
|
|
||||||
# Multiprocessing check for broken sem_getvalue
|
# Multiprocessing check for broken sem_getvalue
|
||||||
{ echo "$as_me:$LINENO: checking for broken sem_getvalue" >&5
|
{ echo "$as_me:$LINENO: checking for broken sem_getvalue" >&5
|
||||||
echo $ECHO_N "checking for broken sem_getvalue... $ECHO_C" >&6; }
|
echo $ECHO_N "checking for broken sem_getvalue... $ECHO_C" >&6; }
|
||||||
|
|
188
configure.in
188
configure.in
|
@ -3065,12 +3065,176 @@ else AC_MSG_ERROR([proper usage is --with-libc=STRING])
|
||||||
fi],
|
fi],
|
||||||
[AC_MSG_RESULT(default LIBC="$LIBC")])
|
[AC_MSG_RESULT(default LIBC="$LIBC")])
|
||||||
|
|
||||||
# ************************************
|
# **************************************************
|
||||||
# * Check for mathematical functions *
|
# * Check for various properties of floating point *
|
||||||
# ************************************
|
# **************************************************
|
||||||
|
|
||||||
LIBS_SAVE=$LIBS
|
AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
|
||||||
LIBS="$LIBS $LIBM"
|
AC_CACHE_VAL(ac_cv_little_endian_double, [
|
||||||
|
AC_TRY_RUN([
|
||||||
|
#include <string.h>
|
||||||
|
int main() {
|
||||||
|
double x = 9006104071832581.0;
|
||||||
|
if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
ac_cv_little_endian_double=yes,
|
||||||
|
ac_cv_little_endian_double=no,
|
||||||
|
ac_cv_little_endian_double=no)])
|
||||||
|
AC_MSG_RESULT($ac_cv_little_endian_double)
|
||||||
|
if test "$ac_cv_little_endian_double" = yes
|
||||||
|
then
|
||||||
|
AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
|
||||||
|
[Define if C doubles are 64-bit IEEE 754 binary format, stored
|
||||||
|
with the least significant byte first])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
|
||||||
|
AC_CACHE_VAL(ac_cv_big_endian_double, [
|
||||||
|
AC_TRY_RUN([
|
||||||
|
#include <string.h>
|
||||||
|
int main() {
|
||||||
|
double x = 9006104071832581.0;
|
||||||
|
if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
ac_cv_big_endian_double=yes,
|
||||||
|
ac_cv_big_endian_double=no,
|
||||||
|
ac_cv_big_endian_double=no)])
|
||||||
|
AC_MSG_RESULT($ac_cv_big_endian_double)
|
||||||
|
if test "$ac_cv_big_endian_double" = yes
|
||||||
|
then
|
||||||
|
AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
|
||||||
|
[Define if C doubles are 64-bit IEEE 754 binary format, stored
|
||||||
|
with the most significant byte first])
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Some ARM platforms use a mixed-endian representation for doubles.
|
||||||
|
# While Python doesn't currently have full support for these platforms
|
||||||
|
# (see e.g., issue 1762561), we can at least make sure that float <-> string
|
||||||
|
# conversions work.
|
||||||
|
AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
|
||||||
|
AC_CACHE_VAL(ac_cv_mixed_endian_double, [
|
||||||
|
AC_TRY_RUN([
|
||||||
|
#include <string.h>
|
||||||
|
int main() {
|
||||||
|
double x = 9006104071832581.0;
|
||||||
|
if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
ac_cv_mixed_endian_double=yes,
|
||||||
|
ac_cv_mixed_endian_double=no,
|
||||||
|
ac_cv_mixed_endian_double=no)])
|
||||||
|
AC_MSG_RESULT($ac_cv_mixed_endian_double)
|
||||||
|
if test "$ac_cv_mixed_endian_double" = yes
|
||||||
|
then
|
||||||
|
AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
|
||||||
|
[Define if C doubles are 64-bit IEEE 754 binary format, stored
|
||||||
|
in ARM mixed-endian order (byte order 45670123)])
|
||||||
|
fi
|
||||||
|
|
||||||
|
# David Gay's code in Python/dtoa.c requires that the FPU uses 53-bit
|
||||||
|
# rounding; this is a particular problem on x86, where the x87 FPU has
|
||||||
|
# a default rounding precision of 64 bits. For gcc/x86, we try to fix
|
||||||
|
# this by:
|
||||||
|
#
|
||||||
|
# (1) using the SSE2 instruction set when available (it usually is
|
||||||
|
# on modern machines)
|
||||||
|
# (2) using inline assembler to get and set the x87 FPU control word
|
||||||
|
# otherwise.
|
||||||
|
#
|
||||||
|
# On AMD64 (aka x86-64), gcc automatically enables use of SSE2
|
||||||
|
# instructions, so we don't bother trying to detect.
|
||||||
|
|
||||||
|
if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
|
||||||
|
then
|
||||||
|
# determine whether we're already using the SSE2 instruction set for math
|
||||||
|
# (e.g., this is true by default on OS X/x86)
|
||||||
|
AC_MSG_CHECKING(whether SSE2 instructions are already enabled for math)
|
||||||
|
if test -n "`$CC -dM -E - </dev/null | grep __SSE2_MATH__`"
|
||||||
|
then
|
||||||
|
ac_sse2_enabled=yes
|
||||||
|
else
|
||||||
|
ac_sse2_enabled=no
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT($ac_sse2_enabled)
|
||||||
|
|
||||||
|
# if we're not using SSE2 already, we need to either enable it
|
||||||
|
# (when available), or use inline assembler to get and set the
|
||||||
|
# 387 control word.
|
||||||
|
if test $ac_sse2_enabled = no
|
||||||
|
then
|
||||||
|
# Check cpuid for SSE2 availability. Bits 25 and 26 of edx tell
|
||||||
|
# us about SSE and SSE2 respectively.
|
||||||
|
AC_MSG_CHECKING(whether SSE2 instructions are available on this CPU)
|
||||||
|
AC_TRY_RUN([
|
||||||
|
int main() {
|
||||||
|
unsigned int ax, bx, cx, dx, func;
|
||||||
|
func = 1U;
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"pushl %%ebx\n\t" /* don't clobber ebx */
|
||||||
|
"cpuid\n\t"
|
||||||
|
"movl %%ebx, %1\n\t"
|
||||||
|
"popl %%ebx"
|
||||||
|
: "=a" (ax), "=r" (bx), "=c" (cx), "=d" (dx)
|
||||||
|
: "a" (func)
|
||||||
|
: "cc" );
|
||||||
|
if ((dx & (1U << 25)) && (dx & (1U << 26)))
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
ac_cv_cpu_has_sse2=yes,
|
||||||
|
ac_cv_cpu_has_sse2=no,
|
||||||
|
ac_cv_cpu_has_sse2=no)
|
||||||
|
AC_MSG_RESULT($ac_cv_cpu_has_sse2)
|
||||||
|
|
||||||
|
# determine whether gcc accepts options to turn on SSE2
|
||||||
|
AC_MSG_CHECKING(whether $CC accepts -msse2 -mfpmath=sse)
|
||||||
|
ac_save_cc="$CC"
|
||||||
|
CC="$CC -msse2 -mfpmath=sse"
|
||||||
|
AC_TRY_RUN([int main() { return 0; }],
|
||||||
|
ac_cv_msse2_ok=yes,
|
||||||
|
ac_cv_msse2_ok=no,
|
||||||
|
ac_cv_msse2_ok=no)
|
||||||
|
CC="$ac_save_cc"
|
||||||
|
AC_MSG_RESULT($ac_cv_msse2_ok)
|
||||||
|
|
||||||
|
if test $ac_cv_cpu_has_sse2 = yes && test $ac_cv_msse2_ok = yes
|
||||||
|
then
|
||||||
|
BASECFLAGS="$BASECFLAGS -msse2 -mfpmath=sse"
|
||||||
|
else
|
||||||
|
# SSE2 doesn't appear to be available. Check that it's okay
|
||||||
|
# to use gcc inline assembler to get and set x87 control word
|
||||||
|
AC_DEFINE(USING_X87_FPU, 1,
|
||||||
|
[Define on x86 hardware if the x87 FPU is being used
|
||||||
|
for floating-point arithmetic])
|
||||||
|
AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
|
||||||
|
AC_TRY_COMPILE([], [
|
||||||
|
unsigned short cw;
|
||||||
|
__asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
|
||||||
|
__asm__ __volatile__ ("fldcw %0" : : "m" (cw));
|
||||||
|
],
|
||||||
|
[have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
|
||||||
|
AC_MSG_RESULT($have_gcc_asm_for_x87)
|
||||||
|
if test "$have_gcc_asm_for_x87" = yes
|
||||||
|
then
|
||||||
|
AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
|
||||||
|
[Define if we can use gcc inline assembler to get and set x87 control word])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Detect whether system arithmetic is subject to x87-style double
|
# Detect whether system arithmetic is subject to x87-style double
|
||||||
# rounding issues. The result of this test has little meaning on non
|
# rounding issues. The result of this test has little meaning on non
|
||||||
|
@ -3078,7 +3242,9 @@ LIBS="$LIBS $LIBM"
|
||||||
# mode is round-to-nearest and double rounding issues are present, and
|
# mode is round-to-nearest and double rounding issues are present, and
|
||||||
# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
|
# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
|
||||||
AC_MSG_CHECKING(for x87-style double rounding)
|
AC_MSG_CHECKING(for x87-style double rounding)
|
||||||
AC_CACHE_VAL(ac_cv_x87_double_rounding, [
|
# $BASECFLAGS may affect the result
|
||||||
|
ac_save_cc="$CC"
|
||||||
|
CC="$CC $BASECFLAGS"
|
||||||
AC_TRY_RUN([
|
AC_TRY_RUN([
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -3101,7 +3267,8 @@ int main() {
|
||||||
],
|
],
|
||||||
ac_cv_x87_double_rounding=no,
|
ac_cv_x87_double_rounding=no,
|
||||||
ac_cv_x87_double_rounding=yes,
|
ac_cv_x87_double_rounding=yes,
|
||||||
ac_cv_x87_double_rounding=no)])
|
ac_cv_x87_double_rounding=no)
|
||||||
|
CC="$ac_save_cc"
|
||||||
AC_MSG_RESULT($ac_cv_x87_double_rounding)
|
AC_MSG_RESULT($ac_cv_x87_double_rounding)
|
||||||
if test "$ac_cv_x87_double_rounding" = yes
|
if test "$ac_cv_x87_double_rounding" = yes
|
||||||
then
|
then
|
||||||
|
@ -3109,6 +3276,13 @@ then
|
||||||
[Define if arithmetic is subject to x87-style double rounding issue])
|
[Define if arithmetic is subject to x87-style double rounding issue])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ************************************
|
||||||
|
# * Check for mathematical functions *
|
||||||
|
# ************************************
|
||||||
|
|
||||||
|
LIBS_SAVE=$LIBS
|
||||||
|
LIBS="$LIBS $LIBM"
|
||||||
|
|
||||||
# Multiprocessing check for broken sem_getvalue
|
# Multiprocessing check for broken sem_getvalue
|
||||||
AC_MSG_CHECKING(for broken sem_getvalue)
|
AC_MSG_CHECKING(for broken sem_getvalue)
|
||||||
AC_TRY_RUN([
|
AC_TRY_RUN([
|
||||||
|
|
|
@ -15,6 +15,18 @@
|
||||||
/* Define if you have the Mach cthreads package */
|
/* Define if you have the Mach cthreads package */
|
||||||
#undef C_THREADS
|
#undef C_THREADS
|
||||||
|
|
||||||
|
/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM
|
||||||
|
mixed-endian order (byte order 45670123) */
|
||||||
|
#undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754
|
||||||
|
|
||||||
|
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most
|
||||||
|
significant byte first */
|
||||||
|
#undef DOUBLE_IS_BIG_ENDIAN_IEEE754
|
||||||
|
|
||||||
|
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the
|
||||||
|
least significant byte first */
|
||||||
|
#undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754
|
||||||
|
|
||||||
/* Define if --enable-ipv6 is specified */
|
/* Define if --enable-ipv6 is specified */
|
||||||
#undef ENABLE_IPV6
|
#undef ENABLE_IPV6
|
||||||
|
|
||||||
|
@ -232,6 +244,10 @@
|
||||||
/* Define to 1 if you have the `gai_strerror' function. */
|
/* Define to 1 if you have the `gai_strerror' function. */
|
||||||
#undef HAVE_GAI_STRERROR
|
#undef HAVE_GAI_STRERROR
|
||||||
|
|
||||||
|
/* Define if we can use gcc inline assembler to get and set x87 control word
|
||||||
|
*/
|
||||||
|
#undef HAVE_GCC_ASM_FOR_X87
|
||||||
|
|
||||||
/* Define if you have the getaddrinfo function. */
|
/* Define if you have the getaddrinfo function. */
|
||||||
#undef HAVE_GETADDRINFO
|
#undef HAVE_GETADDRINFO
|
||||||
|
|
||||||
|
@ -970,6 +986,10 @@
|
||||||
/* Define if you want to use computed gotos in ceval.c. */
|
/* Define if you want to use computed gotos in ceval.c. */
|
||||||
#undef USE_COMPUTED_GOTOS
|
#undef USE_COMPUTED_GOTOS
|
||||||
|
|
||||||
|
/* Define on x86 hardware if the x87 FPU is being used for floating-point
|
||||||
|
arithmetic */
|
||||||
|
#undef USING_X87_FPU
|
||||||
|
|
||||||
/* Define if a va_list is an array of some kind */
|
/* Define if a va_list is an array of some kind */
|
||||||
#undef VA_LIST_IS_ARRAY
|
#undef VA_LIST_IS_ARRAY
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue