rtel wrote on Friday, October 04, 2013:
Did I missed something or _impure_ptr only is initialized in vTaskSwitchContext().
Hopefully you missed something, but like I say in the comments, I don’t use the newlib stuff myself so I am reliant on the people who requested its existence to let me know if anything is wrong.
prvInitialiseTCBVariables() (in tasks.c) is called to initialise the task control block of a task when the task is created - not when the task is first switched in. prvInitialiseTCBVariables() contains the following code which, I think, means each task has its own initialised impure_ptr.
#if ( configUSE_NEWLIB_REENTRANT == 1 )
/* Initialise this task's Newlib reent structure. */
_REENT_INIT_PTR( ( &( pxTCB->xNewLib_reent ) ) );
#endif /* configUSE_NEWLIB_REENTRANT */
Second: I think, that you should use _REENT macro instead of _impure_ptr directly
So the line:
_impure_ptr = &( pxCurrentTCB->xNewLib_reent );
_REENT = &( pxCurrentTCB->xNewLib_reent );
Is that right? Will everything else still compile ok?