From 97cf44cbe068fc6885baa2c179ea3b048ddfa24d Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Fri, 17 Jun 2022 21:57:11 +0800 Subject: [PATCH] freertos: Fix SMP FreeRTOS TSLP deletion callback tests The TLSP deletion callback feature is not compatible with the CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP option. However, the "freertos_options" unit test configuration will enable that option. This commit disables all CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP related features when compiling with SMP FreeRTOS. --- components/freertos/Kconfig | 1 + components/pthread/CMakeLists.txt | 2 +- components/pthread/pthread_local_storage.c | 26 ++++++++-------------- tools/ci/check_copyright_ignore.txt | 1 - 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index 134b181f42..eb55bf2b48 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -296,6 +296,7 @@ menu "FreeRTOS" config FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP # Todo: This is incompatible with SMP FreeRTOS. See if this can be deprecated (IDF-4986) + depends on !FREERTOS_SMP bool "Enable static task clean up hook" default n help diff --git a/components/pthread/CMakeLists.txt b/components/pthread/CMakeLists.txt index addc69d324..da1d4235d1 100644 --- a/components/pthread/CMakeLists.txt +++ b/components/pthread/CMakeLists.txt @@ -13,7 +13,7 @@ list(APPEND extra_link_flags "-u pthread_include_pthread_cond_impl") list(APPEND extra_link_flags "-u pthread_include_pthread_local_storage_impl") list(APPEND extra_link_flags "-u pthread_include_pthread_rwlock_impl") -if(CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP) +if(CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP AND NOT CONFIG_FREERTOS_SMP) # See IDF-4955 target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=vPortCleanUpTCB") endif() diff --git a/components/pthread/pthread_local_storage.c b/components/pthread/pthread_local_storage.c index e784c4cb6b..98f5f88155 100644 --- a/components/pthread/pthread_local_storage.c +++ b/components/pthread/pthread_local_storage.c @@ -1,16 +1,8 @@ -// Copyright 2017 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include #include @@ -150,7 +142,7 @@ static void pthread_local_storage_thread_deleted_callback(int index, void *v_tls free(tls); } -#if defined(CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP) +#if CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP && !CONFIG_FREERTOS_SMP // IDF-4955 /* Called from FreeRTOS task delete hook */ void pthread_local_storage_cleanup(TaskHandle_t task) { @@ -171,7 +163,7 @@ void __wrap_vPortCleanUpTCB(void *tcb) pthread_local_storage_cleanup(tcb); __real_vPortCleanUpTCB(tcb); } -#endif +#endif // CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP && !CONFIG_FREERTOS_SMP /* this function called from pthread_task_func for "early" cleanup of TLS in a pthread */ void pthread_internal_local_storage_destructor_callback(void) @@ -182,14 +174,14 @@ void pthread_internal_local_storage_destructor_callback(void) /* remove the thread-local-storage pointer to avoid the idle task cleanup calling it again... */ -#if defined(CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP) +#if CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP && !CONFIG_FREERTOS_SMP // IDF-4955 vTaskSetThreadLocalStoragePointer(NULL, PTHREAD_TLS_INDEX, NULL); #else vTaskSetThreadLocalStoragePointerAndDelCallback(NULL, PTHREAD_TLS_INDEX, NULL, NULL); -#endif +#endif // CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP && !CONFIG_FREERTOS_SMP } } diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index ad8f08b445..cd3015d303 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -1094,7 +1094,6 @@ components/protocomm/src/common/protocomm_priv.h components/protocomm/src/security/security0.c components/pthread/pthread_cond_var.c components/pthread/pthread_internal.h -components/pthread/pthread_local_storage.c components/pthread/test/test_cxx_cond_var.cpp components/pthread/test/test_cxx_std_future.cpp components/pthread/test/test_pthread.c