Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@
#include <reent.h>
#endif

#ifdef configNEWLIB_REENTRANT_IS_DYNAMIC
#if ( configUSE_NEWLIB_REENTRANT != 1 )
#error configUSE_NEWLIB_REENTRANT must be defined to 1 to enable configNEWLIB_REENTRANT_IS_DYNAMIC
#endif
#else /* configNEWLIB_REENTRANT_IS_DYNAMIC */
#define configNEWLIB_REENTRANT_IS_DYNAMIC 0
#endif /* configNEWLIB_REENTRANT_IS_DYNAMIC */

/*
* Check all the required application specific macros have been defined.
* These macros are application specific and (as downloaded) are defined
Expand Down
18 changes: 12 additions & 6 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2854,15 +2854,18 @@ void vTaskStartScheduler( void )
* starts to run. */
portDISABLE_INTERRUPTS();

#if ( configUSE_NEWLIB_REENTRANT == 1 )
#if ( ( configUSE_NEWLIB_REENTRANT == 1 ) && ( configNEWLIB_REENTRANT_IS_DYNAMIC == 0 ) )
{
/* Switch Newlib's _impure_ptr variable to point to the _reent
* structure specific to the task that will run first.
* See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
* for additional information. */
* for additional information.
*
* Note: Updating the _impure_ptr is not required when Newlib is compiled with
* __DYNAMIC_REENT__ enabled. The port should provide __getreent() instead. */
_impure_ptr = &( pxCurrentTCB->xNewLib_reent );
}
#endif /* configUSE_NEWLIB_REENTRANT */
#endif /* ( configUSE_NEWLIB_REENTRANT == 1 ) && ( configNEWLIB_REENTRANT_IS_DYNAMIC == 0 ) */

xNextTaskUnblockTime = portMAX_DELAY;
xSchedulerRunning = pdTRUE;
Expand Down Expand Up @@ -3945,15 +3948,18 @@ void vTaskSwitchContext( BaseType_t xCoreID )
}
#endif

#if ( configUSE_NEWLIB_REENTRANT == 1 )
#if ( ( configUSE_NEWLIB_REENTRANT == 1 ) && ( configNEWLIB_REENTRANT_IS_DYNAMIC == 0 ) )
{
/* Switch Newlib's _impure_ptr variable to point to the _reent
* structure specific to this task.
* See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
* for additional information. */
* for additional information.
*
* Note: Updating the _impure_ptr is not required when Newlib is compiled with
* __DYNAMIC_REENT__ enabled. The the port should provide __getreent() instead. */
_impure_ptr = &( pxCurrentTCB->xNewLib_reent );
}
#endif /* configUSE_NEWLIB_REENTRANT */
#endif /* ( configUSE_NEWLIB_REENTRANT == 1 ) && ( configNEWLIB_REENTRANT_IS_DYNAMIC == 0 ) */
}
}
portRELEASE_ISR_LOCK();
Expand Down