_REENT->_errno v. extern int errno

Shaun Jackman sjackman@gmail.com
Tue Dec 6 17:16:00 GMT 2005


There's something funny going on with errno. The libgloss ARM
implementation includes <errno.h>, and so stores its errno result
direclty in _REENT->_errno. REENTRANT_SYSCALLS_PROVIDED is not
defined, so write, for example, calls _write in libgloss, and not
_write_r. All is good. However, a function such as __swrite calls
_write_r instead of _write. _write_r does a funny little fix up where
it assumes the OS layer (libgloss) stores the errno result in extern
int errno, and not in _REENT->_errno.

syscalls/syswrite.c assumes the OS layer stores errno in _REENT->_errno.
reent/writer.c assumes the OS layer stores errno in extern int errno.

It seems to me reent/writer.c is broken, or at least should be told
through a define that the errno result is already in _REENT->_errno.

Cheers,
Shaun



More information about the Newlib mailing list