[PATCH 0/5] newlib: libm: long double fixes

Jeff Johnston jjohnstn@redhat.com
Thu Oct 29 21:36:46 GMT 2026


Hi Bernie,

Sorry for the late reply.  The patch set has been pushed to the repo.  The
first patch was not
needed because I had regenerated the Makefile.in recently.

-- Jeff J.

-

On Thu, Oct 29, 2026 at 4:48 PM Bernie Innocenti via Newlib <
newlib@sourceware.org> wrote:

> Should I change anything in this patch series?
>
> We're carrying a few more fixes and improvements in the generic parts of
> our m68k-amigaos fork that I'd like to upstream over time.
>
> _ // Bernie Innocenti
> \X/  https://codewiz.org/
>
>
> On 10/17/26 18:40, Bernie Innocenti wrote:
> > Fixes for the long double math that newlib took from FreeBSD, found while
> > porting the ld80 code to m68k (68881 extended format).  Patches 2-4
> affect
> > every target with a wide long double; patch 5 only m68k.
> >
> > 1: Makefile.in was not regenerated after libc/sys/atari was added; this
> >     keeps that churn out of patch 2.
> > 2: the ld80/ld128 argument reduction passes no table to newlib's
> >     six-argument __kernel_rem_pio2(), so sinl(), cosl() and tanl() of a
> >     large argument use a garbage pointer.
> > 3: hypotl() overflows above about 2^8192 and underflows to 0 below about
> >     2^-8223.
> > 4: sqrtl() is one ulp off for about half of all arguments on x86.
> > 5: struct ieee_ext lacks the big-endian 80-bit layout, so sqrtl() on m68k
> >     read the wrong bytes.
> >
> > Patches 3 and 4 were checked on x86_64 against glibc (2 million sqrtl()
> > arguments identical, 500000 hypotl() pairs within 2 ulp).  All five were
> > also tested on m68k-amigaos, with soft-float and 68881 builds, as part of
> > a larger long double port, against high-precision reference values.
> >
> > Bernie Innocenti (5):
> >    newlib: Regenerate Makefile.in
> >    newlib: libm: pass a long double 2/pi table to __kernel_rem_pio2()
> >    newlib: libm: hypotl: avoid overflow and spurious underflow
> >    newlib: libm: sqrtl: round correctly for 80-bit long double
> >    newlib: ieeefp.h: add the big-endian 80-bit extended layout
> >
> >   newlib/Makefile.in               | 657 +++++++++++++++++--------------
> >   newlib/libc/include/ieeefp.h     |   9 +
> >   newlib/libm/common/sqrtl.c       |  96 +++++
> >   newlib/libm/ld/Makefile.inc      |   1 +
> >   newlib/libm/ld/k_rem_pio2l_tbl.c | 123 ++++++
> >   newlib/libm/ld/math_private.h    |   4 +-
> >   newlib/libm/ld128/e_rem_pio2l.h  |   2 +-
> >   newlib/libm/ld80/e_rem_pio2l.h   |   2 +-
> >   newlib/libm/math/el_hypot.c      |  34 +-
> >   9 files changed, 619 insertions(+), 309 deletions(-)
> >   create mode 100644 newlib/libm/ld/k_rem_pio2l_tbl.c
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/newlib/attachments/20261029/690fe215/attachment.htm>


More information about the Newlib mailing list