Skip to content

Commit 7215c89

Browse files
authored
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 <paulhollinsky@gmail.com>
1 parent 7081e76 commit 7215c89

File tree

1 file changed

+2
-17
lines changed
  • portable/ThirdParty/GCC/Posix

1 file changed

+2
-17
lines changed

portable/ThirdParty/GCC/Posix/port.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -165,30 +165,15 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
165165
thread = ( Thread_t * ) ( pxTopOfStack + 1 ) - 1;
166166
pxTopOfStack = ( StackType_t * ) thread - 1;
167167

168-
#ifdef __APPLE__
169-
pxEndOfStack = ( StackType_t * ) mach_vm_round_page( pxEndOfStack );
170-
#endif
171-
168+
/* Ensure that there is enough space to store Thread_t on the stack. */
172169
ulStackSize = ( size_t ) ( pxTopOfStack + 1 - pxEndOfStack ) * sizeof( *pxTopOfStack );
173-
174-
#ifdef __APPLE__
175-
ulStackSize = mach_vm_trunc_page( ulStackSize );
176-
#endif
170+
configASSERT( ulStackSize > sizeof( Thread_t ) );
177171

178172
thread->pxCode = pxCode;
179173
thread->pvParams = pvParameters;
180174
thread->xDying = pdFALSE;
181175

182-
/* Ensure ulStackSize is at least PTHREAD_STACK_MIN */
183-
ulStackSize = (ulStackSize < ( size_t ) ( PTHREAD_STACK_MIN ) ) ? ( size_t ) ( PTHREAD_STACK_MIN ) : ulStackSize;
184-
185176
pthread_attr_init( &xThreadAttributes );
186-
iRet = pthread_attr_setstacksize( &xThreadAttributes, ulStackSize );
187-
188-
if( iRet != 0 )
189-
{
190-
fprintf( stderr, "[WARN] pthread_attr_setstacksize failed with return value: %d. Default stack size will be used.\n", iRet );
191-
}
192177

193178
thread->ev = event_create();
194179

0 commit comments

Comments
 (0)