This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
why "Reentrant covers for OS subroutines" use global errno?
- From: Can Finner <can dot finner at gmail dot com>
- To: newlib at sourceware dot org
- Date: Tue, 9 Aug 2011 17:31:28 +0800
- Subject: why "Reentrant covers for OS subroutines" use global errno?
Hi,
I am studying the reentrancy mechanism in newlib/libgloss, and read
several threads in newlib mail archive,
I still cannot understand following question.
Why do "Reentrant covers for OS subroutines"(in libc/reent/) use
global errno variable with codes like:
#include <errno.h>
#undef errno
extern int errno;
It is said the system can achieve reentrancy by implementing its own
__getreent function,
defining macro __DYNAMIC_REENT__ and implementing libgloss with
errno.h directly.
However, with routines in libc/reent directory, system won't be
reentrant unless defining macro
REENTRANT_SYSCALLS_PROVIDED and implementing _r versions of syscalls
in libgloss.
Think about calling sequence of a simple case for arm:
fwrite --> __swrite --> _write_r(in libc/reent) --> _write(in libgloss/arm)
routine _write_r uses global errno variable, which breaks the
reentrancy in the calling sequence.
Did I misunderstand the reentrancy mechanism in newlib/libgloss or
something wrong?
Please help, thanks in advance.
--
Regards.