Blackfin & printf()/fprintf()

Jeff Johnston jjohnstn@redhat.com
Thu Mar 27 20:22:00 GMT 2008


Sebastian Dressler wrote:
> Sebastian Dressler wrote:
>   
>> Ok, it seems now, that the sbrk call is broken, i've tested that with
>> malloc ... it fails. So i'll hang in there and fix it first. Maybe it
>> works then...
>>
>>     
>
> Well...i've fixed sbrk and malloc behaves correct now, but nothing changed
> in the behavior of printf. I've debugged it, and found out, that something
> goes wrong, when vfprintf checks the fp. I assume that stdin/out/err is not
> initialized.
>
> After making some google-research i found out, that maybe _sinit() should be
> called or the the _REENT structure should be initialized. Since i don't use
> reentrancy, i'm a bit confused now...
>
> Sebastian
>   
You use the reentrancy structure regardless of threads.  It is used to 
store the std streams, errno, the strtok last pointer, etc...  Now, if 
you look at libc/stdio/local.h, you will see that CHECK_INIT is set up 
to look at the reentrancy struct to see if the std streams are set up.  
If not, it calls __sinit().  If you don't have a properly initialized 
reentrancy structure, then you have problems.  So, start there and look 
at the _sdidinit field to ensure it is false to start with and that you 
end up calling __sinit().  The default reentrancy structure _impure_data 
which is referenced by the _REENT macro, is initialized in 
libc/reent/impure.c.

-- Jeff J.



More information about the Newlib mailing list