From 915787249a6313abf5158a49b5e6e8884d0c5f5f Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Tue, 8 Nov 2022 17:48:48 +0800 Subject: [PATCH] freertos(IDF): Provide default value to configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS This commit updates how configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS is defined by default it to 0 if not defined elsewhere. Dependent code now check for "configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1" instead. --- .../include/freertos/FreeRTOS.h | 6 +++++- .../FreeRTOS-Kernel/include/freertos/task.h | 2 +- components/freertos/FreeRTOS-Kernel/tasks.c | 18 +++++++++--------- .../include/freertos/FreeRTOSConfig.h | 4 +++- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/components/freertos/FreeRTOS-Kernel/include/freertos/FreeRTOS.h b/components/freertos/FreeRTOS-Kernel/include/freertos/FreeRTOS.h index 49ffc0c9c9..bd83336fd8 100644 --- a/components/freertos/FreeRTOS-Kernel/include/freertos/FreeRTOS.h +++ b/components/freertos/FreeRTOS-Kernel/include/freertos/FreeRTOS.h @@ -228,6 +228,10 @@ #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0 #endif +#ifndef configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS + #define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS 0 +#endif + #ifndef configUSE_RECURSIVE_MUTEXES #define configUSE_RECURSIVE_MUTEXES 0 #endif @@ -1231,7 +1235,7 @@ typedef struct xSTATIC_TCB #endif #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) void * pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; - #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) + #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 ) void * pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; #endif #endif diff --git a/components/freertos/FreeRTOS-Kernel/include/freertos/task.h b/components/freertos/FreeRTOS-Kernel/include/freertos/task.h index 152e822592..6a9879a7a5 100644 --- a/components/freertos/FreeRTOS-Kernel/include/freertos/task.h +++ b/components/freertos/FreeRTOS-Kernel/include/freertos/task.h @@ -2024,7 +2024,7 @@ uint8_t * pxTaskGetStackStart( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; void * pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) PRIVILEGED_FUNCTION; - #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) + #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 ) /** * Prototype of local storage pointer deletion callback. diff --git a/components/freertos/FreeRTOS-Kernel/tasks.c b/components/freertos/FreeRTOS-Kernel/tasks.c index f421f99694..7ac5c92a4b 100644 --- a/components/freertos/FreeRTOS-Kernel/tasks.c +++ b/components/freertos/FreeRTOS-Kernel/tasks.c @@ -340,7 +340,7 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) void * pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; - #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) + #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 ) TlsDeleteCallbackFunction_t pvThreadLocalStoragePointersDelCallback[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; #endif #endif @@ -539,7 +539,7 @@ static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ) PRIVILEGED_FUNCTION; /* Function to call the Thread Local Storage Pointer Deletion Callbacks. Will be * called during task deletion before prvDeleteTCB is called. */ -#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) +#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 ) static void prvDeleteTLS( TCB_t * pxTCB ); #endif @@ -1486,7 +1486,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) if( xFreeNow == pdTRUE ) { - #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) + #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 ) prvDeleteTLS( pxTCB ); #endif @@ -4378,7 +4378,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) - #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) + #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 ) void vTaskSetThreadLocalStoragePointerAndDelCallback( TaskHandle_t xTaskToSet, BaseType_t xIndex, @@ -4405,7 +4405,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) } - #else /* if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) */ + #else /* if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 ) */ void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void * pvValue ) @@ -4420,7 +4420,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters ) taskEXIT_CRITICAL( &xKernelLock ); } } - #endif /* configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS */ + #endif /* configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 */ #endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */ /*-----------------------------------------------------------*/ @@ -4557,7 +4557,7 @@ static void prvCheckTasksWaitingTermination( void ) if( pxTCB != NULL ) /*Call deletion callbacks and free TCB memory */ { - #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) + #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 ) prvDeleteTLS( pxTCB ); #endif prvDeleteTCB( pxTCB ); @@ -4892,7 +4892,7 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) #endif /* INCLUDE_vTaskDelete */ /*-----------------------------------------------------------*/ -#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) +#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 ) static void prvDeleteTLS( TCB_t * pxTCB ) { @@ -4907,7 +4907,7 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) } } -#endif /* ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) */ +#endif /* ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) && ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS == 1 ) */ /*-----------------------------------------------------------*/ diff --git a/components/freertos/esp_additions/include/freertos/FreeRTOSConfig.h b/components/freertos/esp_additions/include/freertos/FreeRTOSConfig.h index c5b1b1cc57..0c6df70c6f 100644 --- a/components/freertos/esp_additions/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/esp_additions/include/freertos/FreeRTOSConfig.h @@ -266,7 +266,9 @@ Note: Include trace macros here and not above as trace macros are dependent on s // ---------------------- Features ------------------------- -#define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS +#ifdef CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS +#define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS 1 +#endif #if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER #define configCHECK_MUTEX_GIVEN_BY_OWNER 1