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: Confusion about possibly unsafe malloc_r?


Thanks Freddie. If I understand your answer correctly, printf's call chain's
use of _GLOBAL_REENT should be OK because this particular memory is
protected by a global lock.

I studied the newlib documentation and looked in syscalls, but did not find
anything explaining how to implement "retargetable locks" as you mention.
I did understand that I must implement env_locks to use set_env/get_env,
and that I did not need to implement the corresponding malloc locks.
I read a half-dozen articles about embedding/porintg newlib and failed
to find this...

Could you point me at documentation (or sources) explaining how
to implement "retargetable locks"?

Thanks for the help!
Best Regards, Dave

On 6/25/2017 2:15 AM, Freddie Chopin wrote:
On Sat, 2017-06-24 at 18:42 -0400, Dave Nadler wrote:
Is this OK? I'm paranoid about thread safety!
Then it's worth mentioning that newlib and FreeRTOS will _NEVER_ be
fully thread safe unless you are using a toolchain with retargetable
locks and your project has support code for these locks.

printf()-style families partially use global reent structure, this is
expected. Trace the calls of the mentioned functions in newlib source
and you'll see that sometimes _GLOBAL_REENT is used, sometimes thread's
reent.

Regards,
FCh

--
Dave Nadler, USA East Coast voice (978) 263-0097,drn@nadler.com, Skype
 Dave.Nadler1


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