This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [RFC]New implementation of C89 streamio for resource limited bare metal systems

> -----Original Message-----
> From: [] On
> Behalf Of Sebastian Huber
> Sent: Thursday, June 06, 2013 7:53 PM
> To:
> 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:
#include <stdio.h>

int main(int a, char *s)
    fprintf (stdout, "%d\n", a);
    fprintf (stderr, "%s\n", s);
    fprintf (stdout, "%c\n", s[0]);

    return 0;

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
--disable-newlib-fseek-optimization --disable-newlib-wide-orient
--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[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.

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]