From 1e51387222dc27f070be42a3d83514949c6dcd89 Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Mon, 31 Jul 2023 16:59:41 +0200 Subject: [PATCH] refactor(freertos): Refactor usage of portSTACK_TYPE to StackType_t portSTACK_TYPE is an internal macro defined by the porting layer. This commit changes all references to StackType_t which is the official type exposed by FreeRTOS. --- .../freertos/FreeRTOS-Kernel-SMP/portable/linux/port.c | 9 +++++---- .../freertos/FreeRTOS-Kernel/portable/linux/port.c | 9 +++++---- .../config/linux/include/freertos/FreeRTOSConfig_arch.h | 2 +- .../test_apps/newlib/main/test_shared_stack_printf.c | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/components/freertos/FreeRTOS-Kernel-SMP/portable/linux/port.c b/components/freertos/FreeRTOS-Kernel-SMP/portable/linux/port.c index 783489d3d8..fc73bbe5ee 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/portable/linux/port.c +++ b/components/freertos/FreeRTOS-Kernel-SMP/portable/linux/port.c @@ -133,9 +133,10 @@ static void prvFatalError( const char *pcCall, int iErrno ) /* * See header file for description. */ -portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, - portSTACK_TYPE *pxEndOfStack, - TaskFunction_t pxCode, void *pvParameters ) +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, + StackType_t *pxEndOfStack, + TaskFunction_t pxCode, + void *pvParameters ) { Thread_t *thread; pthread_attr_t xThreadAttributes; @@ -148,7 +149,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, * Store the additional thread data at the start of the stack. */ thread = (Thread_t *)(pxTopOfStack + 1) - 1; - pxTopOfStack = (portSTACK_TYPE *)thread - 1; + pxTopOfStack = (StackType_t *)thread - 1; ulStackSize = (pxTopOfStack + 1 - pxEndOfStack) * sizeof(*pxTopOfStack); thread->pxCode = pxCode; diff --git a/components/freertos/FreeRTOS-Kernel/portable/linux/port.c b/components/freertos/FreeRTOS-Kernel/portable/linux/port.c index b26193863a..6f7b3a9648 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/linux/port.c +++ b/components/freertos/FreeRTOS-Kernel/portable/linux/port.c @@ -124,9 +124,10 @@ static void prvFatalError( const char *pcCall, int iErrno ) /* * See header file for description. */ -portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, - portSTACK_TYPE *pxEndOfStack, - TaskFunction_t pxCode, void *pvParameters ) +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, + StackType_t *pxEndOfStack, + TaskFunction_t pxCode, + void *pvParameters ) { Thread_t *thread; pthread_attr_t xThreadAttributes; @@ -139,7 +140,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, * Store the additional thread data at the start of the stack. */ thread = (Thread_t *)(pxTopOfStack + 1) - 1; - pxTopOfStack = (portSTACK_TYPE *)thread - 1; + pxTopOfStack = (StackType_t *)thread - 1; ulStackSize = (pxTopOfStack + 1 - pxEndOfStack) * sizeof(*pxTopOfStack); thread->pxCode = pxCode; diff --git a/components/freertos/config/linux/include/freertos/FreeRTOSConfig_arch.h b/components/freertos/config/linux/include/freertos/FreeRTOSConfig_arch.h index 61a92e478b..4530bc0fd3 100644 --- a/components/freertos/config/linux/include/freertos/FreeRTOSConfig_arch.h +++ b/components/freertos/config/linux/include/freertos/FreeRTOSConfig_arch.h @@ -25,7 +25,7 @@ * pthread has a minimal stack size which currently is 16KB. * The rest is for additional structures of the POSIX/Linux port. * This is a magic number since PTHREAD_STACK_MIN seems to not be a constant. */ -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) ( 0x4000 + 40 ) / sizeof( portSTACK_TYPE ) ) +#define configMINIMAL_STACK_SIZE ( ( StackType_t ) ( 0x4000 + 40 ) / sizeof( StackType_t ) ) /* Currently not used in Linux POSIX simulator */ #define configMAX_API_CALL_INTERRUPT_PRIORITY 0 diff --git a/components/newlib/test_apps/newlib/main/test_shared_stack_printf.c b/components/newlib/test_apps/newlib/main/test_shared_stack_printf.c index 2f40c0dbe8..0fd2e0742f 100644 --- a/components/newlib/test_apps/newlib/main/test_shared_stack_printf.c +++ b/components/newlib/test_apps/newlib/main/test_shared_stack_printf.c @@ -42,7 +42,7 @@ void another_external_stack_function(void) TEST_CASE("test printf using shared buffer stack", "[newlib]") { - portSTACK_TYPE *shared_stack = malloc(SHARED_STACK_SIZE); + StackType_t *shared_stack = malloc(SHARED_STACK_SIZE); TEST_ASSERT_NOT_NULL(shared_stack);