stdio_ext.h function implementations

Yaakov Selkowitz yselkowi@redhat.com
Thu Dec 11 05:36:00 GMT 2014


On 2014-12-10 03:40, Corinna Vinschen wrote:
> On Dec  9 14:58, Yaakov Selkowitz wrote:
>> Currently, the bulk of the <stdio_ext.h> functions[1][2] are implemented as
>> inline code, or macros on non-gcc-compatible toolchains.  However, there are
>> a few issues with that:
>>
>> * Header-only implementations result in false negatives from AC_CHECK_FUNC
>> tests and the like.  For instance, cpio FTBFS on Cygwin currently because it
>> tries to implement a replacement for a "missing" __fpending which conflicts
>> with the one already in <stdio_ext.h>.
>>
>> * Macro implementations of libc functions need to be undef'ed and backed by
>> real functions with C++ (otherwise you get syntax errors in the ::func
>> form).  Are the inline implementations used by GCC safe for these purposes?
>
> Apart from the fact that the header was broken (too many "inline", fixed
> now), inline functions are safe.  ::__fpending(stdin) is a valid expression.
>
>> * No documentation is generated for these functions.

Patch attached; it also fixes the spelling of __fwritable() to match 
Solaris and glibc.

Note that this code will only be pulled in by (1) AC_CHECK_FUNC 
configure tests or the like, (2) a non-__GNUC__-defining C++ compiler 
(IOW *not* g++, clang++, or icpc, nor *any* _C_ compiler), or (3) 
dlopen()ing these functions from a shared libc (e.g. Cygwin).  In all 
other cases, the inlines/macros in <stdio_ext.h> will be used. 
Therefore, I see little loss in providing a single .c file for these.

These are #ifndef __rtems__ because they have chosen not to support 
<stdio_ext.h> at all.

The functions call _newlib_flockfile_{start,end} even though the macros 
do not, to match the behaviour of clearerr() and feof().

-- 
Yaakov Selkowitz
Associate Software Engineer, ARM
Red Hat, Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newlib-stdio_ext.patch
Type: text/x-patch
Size: 11009 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20141211/ba62e502/attachment.bin>


More information about the Newlib mailing list