Re: undefined references since newlib-3.2.0

Keith Packard via Newlib <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Josef Wolf <[email protected]> writes:

> This patch replaces Balloc() by eBalloc() which calls __assert_func() on
> failure which in turn calls exit() and/or abort()

As an interim step, having a fix available sooner was a good thing.

> Shouldn't those library functions simply report the error by returning NULL to
> the caller and let the application handle the situation?

It's complicated by the libc API which doesn't have defined error return
values for all of the affected APIs. Glibc has similar failure modes;
using those is probably the best option for newlib.

I've patched this code in picolibc (a newlib fork designed for embedded
systems) to track the malloc failures and return status information back
to applications. Interested parties might want to port those fixes back
to newlib.

https://github.com/keith-packard/picolibc/commit/dad1bd20fb927fb14a63d7951b0441f1cec73bf8
https://github.com/keith-packard/picolibc/commit/9fc3006ef9fec4a72b6dd29d2b691c1cc386e8f1

I've also implemented the recent 'ryu' float/string conversion code,
which performs exact (i.e. round-trip-able) conversions with much lower
precision (128bit for 64-bit floats, 64-bit for 32-bit floats). As a
result, that code does all of its operations on the stack and doesn't
use malloc at all, eliminating this particular source of errors. That
code was not writen for the newlib stdio bits, but instead for the
picolibc tinystdio bits. Still, it might serve as a basis for a newlib
port.

-- 
-keith
signature.asc (application/pgp-signature, 832 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAl7kGDsACgkQ2yIaaQAA
ABFKcw/+KL7eygvSiKxvKrTQbSps+hIFnQ9LnewuzvxzeyOwvgppHzGknQxKPhdh
xnPZ+0+5//PmLDq3OfPoxUjPeVCGgCw8UCRej+LRur2lbpy9XAPJwpMQZj4vRr3c
n95JyO+nhwdm/1lCkECUDlwpiTkaDqSLijKARojHZwRxu545ZXRWymTr0a3R54Ei
AbmreQ0W4beEu5Sd4cM/BPE4GmZDHZ3yduXgZRNjXGP20Cv/ip0mo6lQu4KSjNHr
qu0ViGLU/n248+V1kBKHYM760Xj1mTzwjTc1hLSHGfpM8cqr+yOC9mPL2IhMyEFW
+fIE//6TRUHjjF9eJAYbz/zD44PNyH6vhZ1JDwIqiYG3fyFijU0h4VBW2Z/H6/zh
fu7FGejkPFSFgCh6ymJq1QwgHteQDIGB1b84LmfEWFYUnF9GcjspTeO2Gxp+aSK2
M58VPH2jdWkMKuxtez12JJN/N0ip72N068qAhYFaKR7zRm5Gb8Cej7s4nkcZLNIF
F3vo12k8FtWWJSKIZgKWp8vfCTee6Y8SpwUl/unL6UQ24RiQGJJQxJl6dl+ctHBt
aKV8jBKWrKn43NfmV1Gx89v7Ww3e3gVzANHXvj2krLPlQelQAt9WFO6kIW9TeiMu
Zr6EeFhRwzS1NYAhNM+He7s1EfkF9+BfMXZ1ve7eYkuQ0fFoiPU=
=kbst
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.