Josef Wolf
2018-10-19 10:19:57 UTC
Hello,
I am using newlib (and its printf) for more than 15 years now.
Now I upgraded to 3.0.0 and see that printf() stops working once write()
returns an error. Looks like printf() sets an error flag on the stream which
needs to be cleared by clearerr().
Unfortunaltey, GCC optimizes printf calls with constant format strings to use
puts() instead of printf. And puts() does NOT honor this error flag.
The result is that, once write() returns an error, only those optimized
printf() 'calls' will be output.
Why are printf/puts inconsisten on the error handling?
Is there a way to "auto-clear" this error flag?
I have not seen this in older newlib releases.
PS: As I investigated the above issue, I've seen that printf() and friends are
using malloc/realloc and things. I'm getting pretty nervous about malloc
usage, since this is an embedded system which is supposed to run for
really long term (years/decades) and fragmentation would be a major issue.
Is it possible to disable malloc usage when compiling newlib?
I am using newlib (and its printf) for more than 15 years now.
Now I upgraded to 3.0.0 and see that printf() stops working once write()
returns an error. Looks like printf() sets an error flag on the stream which
needs to be cleared by clearerr().
Unfortunaltey, GCC optimizes printf calls with constant format strings to use
puts() instead of printf. And puts() does NOT honor this error flag.
The result is that, once write() returns an error, only those optimized
printf() 'calls' will be output.
Why are printf/puts inconsisten on the error handling?
Is there a way to "auto-clear" this error flag?
I have not seen this in older newlib releases.
PS: As I investigated the above issue, I've seen that printf() and friends are
using malloc/realloc and things. I'm getting pretty nervous about malloc
usage, since this is an embedded system which is supposed to run for
really long term (years/decades) and fragmentation would be a major issue.
Is it possible to disable malloc usage when compiling newlib?
--
Josef Wolf
***@raven.inka.de
Josef Wolf
***@raven.inka.de