Initializing stdio on a powerpc target
Likely, Grant
Grant.Likely@gdcanada.com
Wed Mar 19 18:33:00 GMT 2003
How do I initialize stdin, stdout and stderr for new threads?
I've got two PPC processors on my board which each has it's own _reent
structure. (__DYNAMIC_REENT__ is defined for newlib). For the first uP,
__getreent() returns _impure_ptr. On the second processor, __getreent()
returns a pointer to switch_impure which is defined as follows:
struct _reent switch_impure = _REENT_INIT(switch_impure);
The first processor stdio works fine. However, on the second processor I
have the following problem:
I call setvbuf(stdout, NULL, _IONBF, 0) to make the stream unbuffered.
Subsequent calls to putchar correctly output without buffering, however
calls to printf get buffered if there is not a carriage return at the end of
the string. So, the following code:
printf("\r\n");
putchar('1');
printf("-Hello-");
putchar('2');
printf(":World:\r\n");
putchar('3');
Creates the following output:
12-Hello-:World:
3
I think that there is a problem with my initialization of switch_impure.
What am I doing wrong?
Thanks,
g.
does not make the stream unbuffered for calls to printf. If
2. printf works fine, but putchar sends characters to the _impure_ptr
stdout, instead of switch_impure stdout
More information about the Newlib
mailing list