This is the mail archive of the newlib@sourceware.org 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: Reduce stack usage of _vfiprintf_r()


W dniu 2012-10-10 17:59, Federico Terraneo pisze:
first of all, am not a newlib devloper, just a regular user. I noticed
the exact same problem in RAM constrained ARM microcontrollers when
using newlib together with an RTOS that I developed. The solution I
found is different though, and is to apply a simple patch to newlib
that redefines BUFSIZ to 512 instead of 1024. That small change later
became part of a larger patch that can be found here:
http://gitorious.org/miosix-kernel/miosix-kernel/blobs/master/miosix/compiler/gcc-patches/newlib.patch
The relevant lines are 32--39.

Glad to hear that I'm not the only one that thinks newlib is "too big" (;


Your solution is "not good enough" - the stack is still wasted, 512 bytes is still a lot - considering that _vfiprintf_r() with my patch uses about 300 bytes of stack, the 512 byte buffer almost triples that usage, so for me that's still too much (; I think dynamic allocation in this place is perfectly reasonable - whatever overhead does malloc have it's better than wasting such amount of stack in every situation (as proven in the first mail). In case of my code I don't expect it to be ever called, because I don't use unbuffered streams.

Regards,
FCh


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