Jeff Johnston
Thu Jan 3 19:47:00 GMT 2008

Vincent Rivière wrote:
> Jeff Johnston a wrote :
>> _isatty is not one of the fundamental syscalls required by newlib.  
>> Remember that newlib's historical origin was to support embedded 
>> platforms and it only required a small set of syscalls to support the 
>> ANSI C plus miscellaneous functions.  There is a rough isatty() 
>> implementation in libc/posix that uses fstat, not _isatty.
>> Platforms that have wanted it have typically just done so directly in 
>> their libgloss implementation or libc/sys (used before libgloss was 
>> created) or they use the libc/posix implementation or they use the 
>> default libgloss/isatty.c version (always returns 1) or they let 
>> libnosys resolve it (always returns 0) just to allow tests to link/run.
> I understand.
> But there are 2 problems :
> 1) isatty() is currently fundamental, because without it, a simple 
> printf() cannot link !
> isatty() is used at the bottom of libc/stdio/makebuf.c
> 2) The isatty() implementation in libgloss/libnosys/isatty.c uses the 
> wrong errno. It should only #include <errno.h>, without #undef errno, 
> extern int errno.
Hmm, there are huge inconsistencies here.  The isatty syscall hasn't 
been made compulsory like the other newlib syscalls in that there is 
neither _isatty or _isatty_r calls in the library, but it should have 
been or at the very least, something like the libc/posix isatty 
implementation should have been exposed to be overridden if desired.

The isatty in libnosys should probably be changed to be consistent with 
other libnosys syscalls and implement _isatty.

It will take some unravelling to see if adding _isatty_r will break 
things or not for existing platforms.  For example, Cygwin is using the 
libc/posix isatty and also uses libc/syscalls which would override 
libc/posix in the case of the same object name.

I need to look at this a bit.

-- Jeff J.

More information about the Newlib mailing list