[En-Nut-Discussion] newLib integration

athomi at bluewin.ch athomi at bluewin.ch
Sat Jun 20 13:10:17 CEST 2009

Hi Thiago

>Given that the Nut/OS only has cooperative threads, not preemptive
>threads, then it already is reentrant :)
I thought about your point but came to the conclusion that i have to disagree.
IMO making newlib reentrant means among others not to use global variables. Acctually newlib uses the variable 
"errno" as a global variable (see the already mentioned article about porting newlib) and this variable has to be 
"converted" into a (at least) task specific variable.

Cooperative or not, you can't garantee that a newlib call (which may set the "errno" global variable) is always 
followed by the check of the function's "return value" (in this case the "errno" variable).

You might argue, that if we define a "design rule" that a newlib call has to be followed by its check of the errno (and 
is not interruptable -- exept of interrupt service routines -- by the cooperative Nut/OS), then the non-reentrant 
newlib functions may work. But i wouldn't count on the awareness of this "design rule" of all developers.



More information about the En-Nut-Discussion mailing list