This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: strerror_r questions
> However,
> newlib's strerror() returns "", not "Unknown error XXX", for
> an unknown string, for three reasons:
> 1. strerror_r must be thread-safe, but it calls strerror, so
> strerror must also be thread-safe in newlib (in general,
> POSIX does not require strerror to be thread-safe, but in
> that case, strerror_r cannot be implemented by calling
> strerror); newlib achieves its thread-safety by returning
> only constant strings (well, newlib also provides the
> _user_sterror hook, which must be thread-safe for all this to
> work) 2. newlib did not set aside any thread-local storage
> for computing an alternate string, and I don't want to change
> struct REENT to add such storage 3. newlib targets embedded
> systems, and dragging in snprintf() to compute an alternate
> string is bloat.
I concur: in a small embedded system, newlib's intended field
of application, strerror() should not attempt to format an
unknown error number into a string. (just for the record)
Konrad Schwarz