Reduce stack usage of _vfiprintf_r()
Thu Oct 11 15:07:00 GMT 2012
W dniu 2012-10-10 19:40, Joel Sherrill pisze:
> One thing to keep in mind is that many of these other libc
> implementations are far from complete. They implement a
> small subset of capabilities.
> Newlib aims for high compatibility with standards while still
> being suitable for use in embedded systems.
> As you note, avr-libc focuses heavily on AVRs with little (no?)
> concern for other CPU architectures. My recollection is that
> it also is a libc subset. Different project goal.
True, but for microcontroller you don't need full compatibility - you
don't have standard streams, you don't have file system, you don't have
clock, etc. etc. etc.
> Corinna's to lower the buffer size or move the routine so
> it isn't inlined would on a first order pass both be acceptable.
> It may make sense to do both.
Making that function not inlined is also fine as long as you don't use
unbuffered streams - for me it's better to have 1kB allocated on heap
than on stack - if you have a multithreaded application each thread
would need an additional 1kB of stack just to occasionally use
unbuffered stream - as opposed to each thread occasionally allocating
and freeing 1kB on heap...
> Another design consideration which sometimes comes into
> play is to limit or forbid malloc()'s after the program completes
> initialization. The malloc() solution would push against this
> rule and require analysis to ensure that all paths free the
> memory. 
I think malloc() all around stdio, so in this case it's fine (;
More information about the Newlib