]> git.sur5r.net Git - freertos/commitdiff
Add Newlib reent support.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 26 Jun 2013 11:37:08 +0000 (11:37 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 26 Jun 2013 11:37:08 +0000 (11:37 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1952 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/include/FreeRTOS.h
FreeRTOS/Source/tasks.c

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