From: richardbarry Date: Sat, 30 May 2009 13:30:40 +0000 (+0000) Subject: Added xTaskGetApplicationTaskTag() function. X-Git-Tag: V5.3.0~12 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5b706d8d13411b4f6a7c00100e5b9cd3606549ce;p=freertos Added xTaskGetApplicationTaskTag() function. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@754 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Source/tasks.c b/Source/tasks.c index 64417e11a..447dff48f 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -1451,6 +1451,35 @@ void vTaskIncrementTick( void ) #endif /*-----------------------------------------------------------*/ +#if ( configUSE_APPLICATION_TASK_TAG == 1 ) + + pdTASK_HOOK_CODE xTaskGetApplicationTaskTag( xTaskHandle xTask ) + { + tskTCB *xTCB; + pdTASK_HOOK_CODE xReturn; + + /* If xTask is NULL then we are setting our own task hook. */ + if( xTask == NULL ) + { + xTCB = ( tskTCB * ) pxCurrentTCB; + } + else + { + xTCB = ( tskTCB * ) xTask; + } + + /* Save the hook function in the TCB. A critical section is required as + the value can be accessed from an interrupt. */ + portENTER_CRITICAL(); + xReturn = xTCB->pxTaskTag; + portEXIT_CRITICAL(); + + return xReturn; + } + +#endif +/*-----------------------------------------------------------*/ + #if ( configUSE_APPLICATION_TASK_TAG == 1 ) portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter ) @@ -1778,7 +1807,12 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed portCHAR * const pcName, unsigned portBASE_TYPE uxPriority ) { /* Store the function name in the TCB. */ - strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned portSHORT ) configMAX_TASK_NAME_LEN ); + #if configMAX_TASK_NAME_LEN > 1 + { + /* Don't bring strncpy into the build unnecessarily. */ + strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned portSHORT ) configMAX_TASK_NAME_LEN ); + } + #endif pxTCB->pcTaskName[ ( unsigned portSHORT ) configMAX_TASK_NAME_LEN - ( unsigned portSHORT ) 1 ] = '\0'; /* This is used as an array index so must ensure it's not too large. */