From 1c35cb3bc90830fb58fbc15f76a16fa36adb7352 Mon Sep 17 00:00:00 2001 From: Darian <32921628+Dazza0@users.noreply.github.com> Date: Sat, 3 Feb 2024 03:46:20 +0800 Subject: [PATCH] Enable xTaskGetCurrentTaskHandleForCore() for single core builds (#978) Enable xTaskGetCurrentTaskHandleForCore() for single core builds --------- Co-authored-by: Paul Bartell Co-authored-by: Ching-Hsin Lee --- include/task.h | 4 +--- tasks.c | 36 ++++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/task.h b/include/task.h index de12f429d..fa53f84d7 100644 --- a/include/task.h +++ b/include/task.h @@ -3574,9 +3574,7 @@ TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION; /* * Return the handle of the task running on specified core. */ -#if ( configNUMBER_OF_CORES > 1 ) - TaskHandle_t xTaskGetCurrentTaskHandleForCore( BaseType_t xCoreID ) PRIVILEGED_FUNCTION; -#endif +TaskHandle_t xTaskGetCurrentTaskHandleForCore( BaseType_t xCoreID ) PRIVILEGED_FUNCTION; /* * Shortcut used by the queue implementation to prevent unnecessary call to diff --git a/tasks.c b/tasks.c index 38a80e2de..037ca2af9 100644 --- a/tasks.c +++ b/tasks.c @@ -6559,24 +6559,28 @@ static void prvResetNextTaskUnblockTime( void ) return xReturn; } - - TaskHandle_t xTaskGetCurrentTaskHandleForCore( BaseType_t xCoreID ) - { - TaskHandle_t xReturn = NULL; - - traceENTER_xTaskGetCurrentTaskHandleForCore( xCoreID ); - - if( taskVALID_CORE_ID( xCoreID ) != pdFALSE ) - { - xReturn = pxCurrentTCBs[ xCoreID ]; - } - - traceRETURN_xTaskGetCurrentTaskHandleForCore( xReturn ); - - return xReturn; - } #endif /* #if ( configNUMBER_OF_CORES == 1 ) */ + TaskHandle_t xTaskGetCurrentTaskHandleForCore( BaseType_t xCoreID ) + { + TaskHandle_t xReturn = NULL; + + traceENTER_xTaskGetCurrentTaskHandleForCore( xCoreID ); + + if( taskVALID_CORE_ID( xCoreID ) != pdFALSE ) + { + #if ( configNUMBER_OF_CORES == 1 ) + xReturn = pxCurrentTCB; + #else /* #if ( configNUMBER_OF_CORES == 1 ) */ + xReturn = pxCurrentTCBs[ xCoreID ]; + #endif /* #if ( configNUMBER_OF_CORES == 1 ) */ + } + + traceRETURN_xTaskGetCurrentTaskHandleForCore( xReturn ); + + return xReturn; + } + #endif /* ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */ /*-----------------------------------------------------------*/