From 26107bf80479346c280818be5e5c6e6e9ac2e6a4 Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Fri, 2 Feb 2024 03:46:16 +0800 Subject: [PATCH 1/2] Enable xTaskGetCurrentTaskHandleForCore() for single core builds --- include/task.h | 4 +--- tasks.c | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/task.h b/include/task.h index 7856b89d2ab..53c33742dc4 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 38a80e2de94..48606d40f0c 100644 --- a/tasks.c +++ b/tasks.c @@ -6559,23 +6559,28 @@ static void prvResetNextTaskUnblockTime( void ) return xReturn; } + #endif /* #if ( configNUMBER_OF_CORES == 1 ) */ - TaskHandle_t xTaskGetCurrentTaskHandleForCore( BaseType_t xCoreID ) - { - TaskHandle_t xReturn = NULL; + TaskHandle_t xTaskGetCurrentTaskHandleForCore( BaseType_t xCoreID ) + { + TaskHandle_t xReturn = NULL; - traceENTER_xTaskGetCurrentTaskHandleForCore( xCoreID ); + traceENTER_xTaskGetCurrentTaskHandleForCore( xCoreID ); - if( taskVALID_CORE_ID( xCoreID ) != pdFALSE ) - { + 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 ); + traceRETURN_xTaskGetCurrentTaskHandleForCore( xReturn ); - return xReturn; - } - #endif /* #if ( configNUMBER_OF_CORES == 1 ) */ + return xReturn; + } #endif /* ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */ /*-----------------------------------------------------------*/ From 39163fae94741f937cd3e6e57f2e78de21780d27 Mon Sep 17 00:00:00 2001 From: Ching-Hsin Lee Date: Fri, 2 Feb 2024 12:22:00 +0800 Subject: [PATCH 2/2] Remove extra curly brackets --- tasks.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tasks.c b/tasks.c index 48606d40f0c..037ca2af901 100644 --- a/tasks.c +++ b/tasks.c @@ -6573,7 +6573,6 @@ static void prvResetNextTaskUnblockTime( void ) xReturn = pxCurrentTCB; #else /* #if ( configNUMBER_OF_CORES == 1 ) */ xReturn = pxCurrentTCBs[ xCoreID ]; - } #endif /* #if ( configNUMBER_OF_CORES == 1 ) */ }