From 5227616e570dc815e7015fe305ac0db15f11c56d Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Tue, 29 Aug 2023 16:48:30 +0800 Subject: [PATCH] refactor(freertos/idf): Implicitly include idf_additions.h from FreeRTOS.h This commit adds an implicit inclusion of `idf_additions.h` to `FreeRTOS.h` in preparation for moving some IDf specific API to `idf_additions.h`. This implict inclusion allows existing code to be continue using these relocated APIs without any changes in header inclusions. Also removed "#pragma once" directive from "freertos_tasks_c_additions.h" since that header is included as a source file. --- .../include/freertos/FreeRTOS.h | 30 +++++++++++++++---- .../include/freertos/task.h | 2 -- .../include/freertos/FreeRTOS.h | 27 ++++++++++++++++- .../freertos_tasks_c_additions.h | 2 -- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/components/freertos/FreeRTOS-Kernel-SMP/include/freertos/FreeRTOS.h b/components/freertos/FreeRTOS-Kernel-SMP/include/freertos/FreeRTOS.h index deef64198a..24dbd653df 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/include/freertos/FreeRTOS.h +++ b/components/freertos/FreeRTOS-Kernel-SMP/include/freertos/FreeRTOS.h @@ -1393,11 +1393,29 @@ typedef StaticStreamBuffer_t StaticMessageBuffer_t; #endif /* *INDENT-ON* */ -/* IDF API additions have been moved to idf_additions.h when building for - * Amazon SMP FreeRTOS. However, the rest of ESP-IDF has not been updated to - * include this header explicitly when calling this additional API. Thus, we - * include this here as a workaround until the rest of ESP-IDF can be updated - * to include idf_additions.h explicitly. */ -#include "freertos/idf_additions.h" +/*----------------------------------------------------------- +* IDF Compatibility +*----------------------------------------------------------*/ + +#ifdef ESP_PLATFORM + + /* + * Include ESP-IDF API additions implicitly for compatibility reasons. + * + * ESP-IDF API additions were previously added directly to FreeRTOS headers + * (e.g., task.h, queue.h). These APIs have now been moved to + * idf_additions.h. + * + * To ensure there are no breaking changes, we include idf_additions.h + * implicitly here so that those API additions are still accessible. Given + * that FreeRTOS.h must be included first before calling any FreeRTOS API, + * any existing source code can continue using these relocated APIs without + * any additional header inclusions via this implicit inclusion. + * + * Todo: Deprecate this implicit inclusion by ESP-IDF v6.0 (IDF-8126) + */ + #include "freertos/idf_additions.h" + +#endif /* ESP_PLATFORM */ #endif /* INC_FREERTOS_H */ diff --git a/components/freertos/FreeRTOS-Kernel-SMP/include/freertos/task.h b/components/freertos/FreeRTOS-Kernel-SMP/include/freertos/task.h index 41d44b5107..4d3158e535 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/include/freertos/task.h +++ b/components/freertos/FreeRTOS-Kernel-SMP/include/freertos/task.h @@ -3321,8 +3321,6 @@ core 0 during startup. void vTaskStartSchedulerOtherCores( void ); #endif // configNUM_CORES > 1 -#include "freertos/idf_additions.h" - #endif //ESP_PLATFORM /* *INDENT-OFF* */ diff --git a/components/freertos/FreeRTOS-Kernel/include/freertos/FreeRTOS.h b/components/freertos/FreeRTOS-Kernel/include/freertos/FreeRTOS.h index e6b6916ab9..5ddfdafdb7 100644 --- a/components/freertos/FreeRTOS-Kernel/include/freertos/FreeRTOS.h +++ b/components/freertos/FreeRTOS-Kernel/include/freertos/FreeRTOS.h @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: MIT * - * SPDX-FileContributor: 2016-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2016-2023 Espressif Systems (Shanghai) CO LTD */ /* @@ -1404,4 +1404,29 @@ typedef StaticStreamBuffer_t StaticMessageBuffer_t; #endif /* *INDENT-ON* */ +/*----------------------------------------------------------- +* IDF Compatibility +*----------------------------------------------------------*/ + +#ifdef ESP_PLATFORM + + /* + * Include ESP-IDF API additions implicitly for compatibility reasons. + * + * ESP-IDF API additions were previously added directly to FreeRTOS headers + * (e.g., task.h, queue.h). These APIs have now been moved to + * idf_additions.h. + * + * To ensure there are no breaking changes, we include idf_additions.h + * implicitly here so that those API additions are still accessible. Given + * that FreeRTOS.h must be included first before calling any FreeRTOS API, + * any existing source code can continue using these relocated APIs without + * any additional header inclusions via this implicit inclusion. + * + * Todo: Deprecate this implicit inclusion by ESP-IDF v6.0 (IDF-8126) + */ + #include "freertos/idf_additions.h" + +#endif /* ESP_PLATFORM */ + #endif /* INC_FREERTOS_H */ diff --git a/components/freertos/esp_additions/freertos_tasks_c_additions.h b/components/freertos/esp_additions/freertos_tasks_c_additions.h index 6dbff63ead..560c57898a 100644 --- a/components/freertos/esp_additions/freertos_tasks_c_additions.h +++ b/components/freertos/esp_additions/freertos_tasks_c_additions.h @@ -4,8 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -#pragma once - #include "sdkconfig.h" #include "freertos/idf_additions.h" #if CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT