EmBitz
Thread safe Newlib Nano heap - Printable Version

+- EmBitz (https://www.embitz.org/forum)
+-- Forum: IDE (https://www.embitz.org/forum/forum-1.html)
+--- Forum: Using EmBitz (https://www.embitz.org/forum/forum-2.html)
+--- Thread: Thread safe Newlib Nano heap (/thread-218.html)



Thread safe Newlib Nano heap - matsb - 12-12-2024

Hi!

I'm working on a STM32G473 project using FreeRTOS.
Due to FLASH memory size limitations, I had to change from using Newlib to Newlib Nano-branch, and with this, I lost malloc/free heap thread safety.

With Newlib, I had the heap thread safe by implementing these functions with a FreeRTOS mutex:

void __malloc_lock(struct _reent * ptr);
void __malloc_unlock(struct _reent * ptr);

But these functions are not called from Newlib Nano.

I've googled around about Newlib Nano-branch, and some older versions does not provide this feature, but other versions seems to support it,
for example on this link: https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commitdiff;h=2665915cfc46aa6403bb2efd473c523d3167e0cb


Any suggestions how I can overcome this?


RE: Thread safe Newlib Nano heap - embitz - 12-12-2024

Writing your own wrappers and use the --wrap option of GCC?