Skip to content
Merged
8 changes: 0 additions & 8 deletions Doc/c-api/float.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,6 @@ endian processor, or ``0`` on little endian processor.
Return value: ``0`` if all is OK, ``-1`` if error (and an exception is set,
most likely :exc:`OverflowError`).

There are two problems on non-IEEE platforms:

* What this does is undefined if *x* is a NaN or infinity.
* ``-0.0`` and ``+0.0`` produce the same bytes string.

.. c:function:: int PyFloat_Pack2(double x, char *p, int le)

Pack a C double as the IEEE 754 binary16 half-precision format.
Expand Down Expand Up @@ -256,9 +251,6 @@ Return value: The unpacked double. On error, this is ``-1.0`` and
:c:func:`PyErr_Occurred` is true (and an exception is set, most likely
:exc:`OverflowError`).

Note that on a non-IEEE platform this will refuse to unpack a bytes string that
represents a NaN or infinity.

.. c:function:: double PyFloat_Unpack2(const char *p, int le)

Unpack the IEEE 754 binary16 half-precision format as a C double.
Expand Down
10 changes: 9 additions & 1 deletion Include/internal/pycore_floatobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ extern "C" {

/* runtime lifecycle */

extern void _PyFloat_InitState(PyInterpreterState *);
extern PyStatus _PyFloat_InitTypes(PyInterpreterState *);
extern void _PyFloat_FiniType(PyInterpreterState *);

Expand Down Expand Up @@ -42,6 +41,15 @@ extern double _Py_parse_inf_or_nan(const char *p, char **endptr);

extern int _Py_convert_int_to_double(PyObject **v, double *dbl);

/* Should match endianness of the platform in most (all?) cases. */

#ifdef DOUBLE_IS_BIG_ENDIAN_IEEE754
# define _PY_FLOAT_BIG_ENDIAN 1
# define _PY_FLOAT_LITTLE_ENDIAN 0
#else
# define _PY_FLOAT_BIG_ENDIAN 0
# define _PY_FLOAT_LITTLE_ENDIAN 1
#endif

#ifdef __cplusplus
}
Expand Down
3 changes: 1 addition & 2 deletions Include/internal/pycore_pymath.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ extern void _Py_set_387controlword(unsigned short);
// (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)
!defined(DOUBLE_IS_BIG_ENDIAN_IEEE754)
# define _PY_SHORT_FLOAT_REPR 0
#endif

Expand Down
8 changes: 2 additions & 6 deletions Include/internal/pycore_runtime_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern "C" {
#include "pycore_debug_offsets.h" // _Py_DebugOffsets_INIT()
#include "pycore_dtoa.h" // _dtoa_state_INIT()
#include "pycore_faulthandler.h" // _faulthandler_runtime_state_INIT
#include "pycore_floatobject.h" // _py_float_format_unknown
#include "pycore_floatobject.h" // _py_float_format_*
#include "pycore_function.h"
#include "pycore_hamt.h" // _PyHamt_BitmapNode_Type
#include "pycore_import.h" // IMPORTS_INIT
Expand Down Expand Up @@ -84,10 +84,6 @@ extern PyTypeObject _PyExc_MemoryError;
.stoptheworld = { \
.is_global = 1, \
}, \
.float_state = { \
.float_format = _py_float_format_unknown, \
.double_format = _py_float_format_unknown, \
}, \
.types = { \
.next_version_tag = _Py_TYPE_VERSION_NEXT, \
}, \
Expand Down Expand Up @@ -233,4 +229,4 @@ extern PyTypeObject _PyExc_MemoryError;
#ifdef __cplusplus
}
#endif
#endif /* !Py_INTERNAL_RUNTIME_INIT_H */
#endif /* !Py_INTERNAL_RUNTIME_INIT_H */
12 changes: 0 additions & 12 deletions Include/internal/pycore_runtime_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@ struct _pymem_allocators {
PyObjectArenaAllocator obj_arena;
};

enum _py_float_format_type {
_py_float_format_unknown,
_py_float_format_ieee_big_endian,
_py_float_format_ieee_little_endian,
};

struct _Py_float_runtime_state {
enum _py_float_format_type float_format;
enum _py_float_format_type double_format;
};

struct pyhash_runtime_state {
struct {
#ifndef MS_WINDOWS
Expand Down Expand Up @@ -270,7 +259,6 @@ struct pyruntimestate {
} audit_hooks;

struct _py_object_runtime_state object_state;
struct _Py_float_runtime_state float_state;
struct _Py_unicode_runtime_state unicode_state;
struct _types_runtime_state types;
struct _Py_time_runtime_state time;
Expand Down
1 change: 0 additions & 1 deletion Include/pymacconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#undef SIZEOF_UINTPTR_T
#undef SIZEOF_PTHREAD_T
#undef WORDS_BIGENDIAN
#undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754
#undef DOUBLE_IS_BIG_ENDIAN_IEEE754
#undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754
#undef HAVE_GCC_ASM_FOR_X87
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Remove support for ancient ARM platforms (ARMv4L and ARMv5L OABI boards),
using mixed-endian representation
for doubles. Patch by Sergey B Kirpichev.
4 changes: 2 additions & 2 deletions Objects/clinic/floatobject.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading