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: "Bin Cheng" <bin dot cheng at arm dot com>
- To: "'Sebastian Huber'" <sebastian dot huber at embedded-brains dot de>, <newlib at sourceware dot org>
- Date: Fri, 7 Jun 2013 17:05:08 +0800
- Subject: RE: [RFC]New implementation of C89 streamio for resource limited bare metal systems
- References: <008201ce61d5$c4ff5840$4efe08c0$ at email@example.com> <51B07833 dot 1090004 at embedded-brains dot de>
> -----Original Message-----
> From: firstname.lastname@example.org [mailto:email@example.com] On
> Behalf Of Sebastian Huber
> Sent: Thursday, June 06, 2013 7:53 PM
> To: firstname.lastname@example.org
> Subject: Re: [RFC]New implementation of C89 streamio for resource limited
> metal systems
> Hello Bin,
> do you have any numbers which compare the code and memory (stack, static,
> dynamic) usage of the current Newlib and your implementation of the
> family functions?
> A weakly referenced floating point support sounds pretty attractive since
> standard Newlib printf() is pretty heavy weight.
I did experiments and compared this implementation with upstream newlib.
For example program:
int main(int a, char *s)
fprintf (stdout, "%d\n", a);
fprintf (stderr, "%s\n", s);
fprintf (stdout, "%c\n", s);
Link it with library compiled with "-Os -ffunction-sections -fdata-sections"
and do "-Wl,--gc-sections". I found some interesting points:
1) With options "--disable-newlib-fvwrite-in-streamio
--enable-newlib-nano-malloc --disable-newlib-io-float", the upstream
newlib's code size is only about 200 bytes larger than this implementation.
Basically this implementation decreases code size by ruling out unnecessary
functions, which has been done by the mentioned options. So this
implementation itself doesn't bring much benefit for code size.
2) This implementation substantially decreases stack usage for printf
routines, because of a char 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.
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.