This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Change defines for stdin, stdout and stderr
- From: Thomas Pfaff <tpfaff at gmx dot net>
- To: newlib at sources dot redhat dot com
- Date: Mon, 16 Jun 2003 16:13:05 +0200
- Subject: Change defines for stdin, stdout and stderr
Hello all,
a few weeks ago i created a patch for cygwin to enable thread safe
errnos by defining __DYNAMIC_REENT__. While this went smoothly (define
__DYNAMIC_REENT__ and create __getreent) and is now included in cygwin i
discovered that stdin, stdout and stderr are defined directly with _REENT.
#define stdin (_REENT->_stdin)
#define stdout (_REENT->_stdout)
#define stderr (_REENT->_stderr)
This is a bit ugly because it requires that every app and lib must be
recompiled for the _REENT change.
To avoid this in the future i would suggest to change the defines for
stdin, stdout and stderr similar to errno.
#define stdin (*__stdin())
extern __FILE **__stdin _PARAMS ((void));
and implement as
__FILE **
__stdin ()
{
return &_REENT->_stdin;
}
Same for stdout and err. This would allow to define and undefine
__DYNAMIC_REENT__ without recompiling user code.
I think that this is cleaner.
Comments are welcome.
TIA,
Thomas