[5/5] newlib: ieeefp.h: add the big-endian 80-bit extended layout
Commit Message
struct ieee_ext only had the x87 field order, so on m68k with a 68881
long double (sign and exponent first, 16 bits of padding, then the
mantissa) libm/common/sqrtl.c read the fields from the wrong bytes and
returned wrong results for almost every argument.
Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Bernie Innocenti <bernie@codewiz.org>
---
newlib/libc/include/ieeefp.h | 9 +++++++++
1 file changed, 9 insertions(+)
@@ -192,10 +192,19 @@ typedef union
typedef struct ieee_ext
{
+#if defined (__IEEE_BIG_ENDIAN) && LDBL_MANT_DIG == 64
+ /* 68881 extended: sign and exponent, 16 bits of padding, mantissa. */
+ __ieee_ext_field_type ext_sign : 1;
+ __ieee_ext_field_type ext_exp : EXT_EXPBITS;
+ __ieee_ext_field_type ext_pad : 16;
+ __ieee_ext_field_type ext_frach : EXT_FRACHBITS;
+ __ieee_ext_field_type ext_fracl : EXT_FRACLBITS;
+#else
__ieee_ext_field_type ext_fracl : EXT_FRACLBITS;
__ieee_ext_field_type ext_frach : EXT_FRACHBITS;
__ieee_ext_field_type ext_exp : EXT_EXPBITS;
__ieee_ext_field_type ext_sign : 1;
+#endif
} ieee_ext;
typedef union ieee_ext_u