[PATCH 1/3] score: Remove _Stack_Adjust_size()

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Apr 16 09:00:08 UTC 2012


On 04/15/2012 08:05 PM, Gedare Bloom wrote:
> Where did the original stack size adjustment come from / what was its
> motivation?

The

uint32_t _Stack_Adjust_size(size_t size)
{
   return size + CPU_STACK_ALIGNMENT;
}

is there since 1995-05-11 19:39:37.  It is probably there since the workspace 
allocator only aligns the memory by CPU_HEAP_ALIGNMENT.  The stack needs to be 
aligned by CPU_STACK_ALIGNMENT.  Thus if these values are arbitrary you have to 
adjust the allocated memory to fit as a stack.  You need to allocate at least 
CPU_STACK_ALIGNMENT - 1 additional bytes to do this.

> Will this break something that was "fixed" by the
> previous approach?

I think this fixed a non-existing problem.  The CPU_HEAP_ALIGNMENT and 
CPU_STACK_ALIGNMENT are roughly the same on all supported architectures.  Also 
the requested stack size must be considerable larger than CPU_STACK_ALIGNMENT, 
otherwise you cannot call any functions.  Thus it is not a problem at all to 
align the memory.

-- 
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list