C Standard Libraries for Real-Time?

ten-techhunter wrote on Friday, August 12, 2011:

For those of you using ARM gcc, you know the question of what C Standard Library to use has to be made before you even compile your toolchain. I’m trying to figure out what toolchain to use with FreeRTOS, and other Real-Time systems like it; preferably something built to produce hard-real-time code.

I would guess that an appropriate C Standard Library would be thread-safe and reentrant. Of course, there has also been some mention of problems when Yagarto went with the reentrant version of newlib. Is there something about FreeRTOS that doesn’t play well with reentrant code?

What C Standard Library is best for Hard-Real-Time projects?

davedoors wrote on Friday, August 12, 2011:

There is not much in FreeRTOS that needs reentrant code. No library functions used by FreeRTOS are not reentrant. If your application uses functions that are not reentrant then you can guard the functions yourself using mutexes or other semaphores. FreeRTOS does not attempt to keep a library context for each task, for example there is no errno per task. If you search this formum hard enough you will find posts that show how people have modified the TCB to had a pointer to their own newlib context, but my advice is, if you are using a microcontroller with limited memory, stay away from newlib. The definition of ‘small’ is relative. Many GCC vendors provide their own libraries (Rowley and Code Red to name two), and FreeRTOS ships with a third party printf/sprintf implementation that is ultra small and reentrant, but does not provide floating point support.

ten-techhunter wrote on Friday, August 12, 2011:

Well yes, but I need reentrancy and thread-safe for my own needs… While I could block off code that is reentrant, I’d prefer to have to do that as little as possible. I didn’t even consider what FreeRTOS needed until I heard there was trouble with the reentrant version of newlib. A useful post, but doesn’t quite answer my questions.