From 7215c89aa81501f60af8df68dfa99fc2c118a293 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Wed, 23 Oct 2024 23:42:27 -0700 Subject: [PATCH] POSIX Port: Remove pthread_attr_setstacksize call (#1161) We have removed the use of pthread_attr_setstack and as a result, the task stack is no longer used as the corresponding pthread's stack. There is no use of calling pthread_attr_setstacksize as the default is always good enough and we don't need to handle OS specific cases. This PR simplifies the code by removing the call to pthread_attr_setstacksize. Signed-off-by: Paul Hollinsky --- portable/ThirdParty/GCC/Posix/port.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/portable/ThirdParty/GCC/Posix/port.c b/portable/ThirdParty/GCC/Posix/port.c index 94e80cc4d..b11e9017f 100644 --- a/portable/ThirdParty/GCC/Posix/port.c +++ b/portable/ThirdParty/GCC/Posix/port.c @@ -165,30 +165,15 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, thread = ( Thread_t * ) ( pxTopOfStack + 1 ) - 1; pxTopOfStack = ( StackType_t * ) thread - 1; - #ifdef __APPLE__ - pxEndOfStack = ( StackType_t * ) mach_vm_round_page( pxEndOfStack ); - #endif - + /* Ensure that there is enough space to store Thread_t on the stack. */ ulStackSize = ( size_t ) ( pxTopOfStack + 1 - pxEndOfStack ) * sizeof( *pxTopOfStack ); - - #ifdef __APPLE__ - ulStackSize = mach_vm_trunc_page( ulStackSize ); - #endif + configASSERT( ulStackSize > sizeof( Thread_t ) ); thread->pxCode = pxCode; thread->pvParams = pvParameters; thread->xDying = pdFALSE; - /* Ensure ulStackSize is at least PTHREAD_STACK_MIN */ - ulStackSize = (ulStackSize < ( size_t ) ( PTHREAD_STACK_MIN ) ) ? ( size_t ) ( PTHREAD_STACK_MIN ) : ulStackSize; - pthread_attr_init( &xThreadAttributes ); - iRet = pthread_attr_setstacksize( &xThreadAttributes, ulStackSize ); - - if( iRet != 0 ) - { - fprintf( stderr, "[WARN] pthread_attr_setstacksize failed with return value: %d. Default stack size will be used.\n", iRet ); - } thread->ev = event_create();