This is the mail archive of the
mailing list for the newlib project.
Re: [RFC]New implementation of C89 streamio for resource limited bare metal systems
- From: Freddie Chopin <freddie_chopin at op dot pl>
- To: newlib at sourceware dot org
- Date: Sat, 08 Jun 2013 13:09:22 +0200
- Subject: Re: [RFC]New implementation of C89 streamio for resource limited bare metal systems
- References: <008201ce61d5$c4ff5840$4efe08c0$ at firstname.lastname@example.org> <51B07833 dot 1090004 at embedded-brains dot de> <009d01ce635e$1fa44ce0$5eece6a0$ at email@example.com> <51B1A688 dot 90809 at op dot pl> <009f01ce6435$22bf26c0$683d7440$ at firstname.lastname@example.org>
W dniu 2013-06-08 12:44, Bin Cheng pisze:
I missed the part that __sbprintf has been changed into non-inline, so the
big buffer isn't a problem anymore. Though __sbprintf can be guarded by an
Yes that's true - the function is not inlined anymore, so the 1024B (or
other size if BUFSIZ is redefined) buffer is allocated on stack only if
you use unbuffered stream. Anyway - I think it would be a nice option to
disable this optimization, so that unbuffered streams would not use so
much stack. For this reason I have to provide my own handling of assert
failure - in MCUs I just don't see the normal version - using fiprintf()
and this 1kB buffer (stderr is unbuffered) - working reliably.
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
*printf to be *iprintf (and the same for scanf). I guess it would be
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)
It requires lots of change of command line options, but yes, this should
It's probably possible to do that with linker script, but I'm not sure
how to do that in a generic way. Doing sth like this:
sprintf = siprintf;
works (you call sprintf, but siprintf is actually called), but this has
a problem that each symbol within EXTERN will be linked, even if not
used... And without EXTERN there's a linker script error that siprintf
symbol is undefined...