Add Newlib reent support.

This commit is contained in:
Richard Barry 2013-06-26 11:37:08 +00:00
parent 4444b4ee68
commit 59f75a12f6
2 changed files with 27 additions and 0 deletions

View file

@ -576,6 +576,10 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
#endif #endif
#ifndef configUSE_NEWLIB_REENTRANT
#define configUSE_NEWLIB_REENTRANT 0
#endif
/* For backward compatability. */ /* For backward compatability. */
#define eTaskStateGet eTaskGetState #define eTaskStateGet eTaskGetState

View file

@ -146,6 +146,14 @@ typedef struct tskTaskControlBlock
unsigned long ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */ unsigned long ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */
#endif #endif
#if ( configUSE_NEWLIB_REENTRANT == 1 )
/* Allocate a Newlib reent structure that is specific to this task.
Note Newlib support has been included by popular demand, but is not
used by the FreeRTOS maintainers themselves, and therefore receives
less rigorous testing than the rest of the FreeRTOS code. */
struct _reent xNewLib_reent;
#endif
} tskTCB; } tskTCB;
@ -1858,6 +1866,14 @@ void vTaskSwitchContext( void )
taskSELECT_HIGHEST_PRIORITY_TASK(); taskSELECT_HIGHEST_PRIORITY_TASK();
traceTASK_SWITCHED_IN(); traceTASK_SWITCHED_IN();
#if ( configUSE_NEWLIB_REENTRANT == 1 )
{
/* Switch Newlib's _impure_ptr variable to point to the _reent
structure specific to this task. */
_impure_ptr = &( pxCurrentTCB->xNewLib_reent );
}
#endif /* configUSE_NEWLIB_REENTRANT */
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -2319,6 +2335,13 @@ portBASE_TYPE x;
( void ) usStackDepth; ( void ) usStackDepth;
} }
#endif /* portUSING_MPU_WRAPPERS */ #endif /* portUSING_MPU_WRAPPERS */
#if ( configUSE_NEWLIB_REENTRANT == 1 )
{
/* Initialise this task's Newlib reent structure. */
_REENT_INIT_PTR( ( &( pxTCB->xNewLib_reent ) ) );
}
#endif /* configUSE_NEWLIB_REENTRANT */
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/