[RFC]New implementation of C89 streamio for resource limited bare metal systems
Freddie Chopin
freddie_chopin@op.pl
Fri Jun 7 09:24:00 GMT 2013
W dniu 2013-06-07 11:05, Bin Cheng pisze:
> 2) This implementation substantially decreases stack usage for printf
> routines, because of a char[1024] buffer in newlib's __sbprintf function.
> This can be fixed by simply disabling the optimization for un-buffered files
> (under configuration options).
>
> So we can even drop this implementation and achieving same code size goal.
An option like that (maybe even an configure option for setting BUFSIZ
without messing with source files [; ) would be great! Unbuffered stream
should be unbuffered [;
> But one challenge is how to make floating point weak symbol without
> re-implement the stream io routines, because floating point is tight coupled
> with integer in current implementation.
Well, if you don't want to use floating point AT ALL you can just
redefine all *printf to be *iprintf (and the same for scanf). I guess it
would be enough to have sth like this added to compilation:
-Dprintf=iprintf -Dfprintf=fiprintf -Dsprintf=siprintf ...
-Dscanf=iscanf -Dfscanf=fiscanf -Dsscanf=siscanf ... (for all available
"types" of these functions)
The only case where this would NOT work is if newlib itself uses
floating point variants of these functions "inside". Does it? In that
case maybe it would be possible to override the symbols via linker
script or by just providing trampoline function(s) (vfprintf() calling
vfiprintf() would probably be enough).
4\/3!!
More information about the Newlib
mailing list