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

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Apr 16 15:24:27 UTC 2012


On 04/16/2012 05:11 PM, Gedare Bloom wrote:
> On Mon, Apr 16, 2012 at 5:00 AM, Sebastian Huber
> <sebastian.huber at embedded-brains.de>  wrote:
>> 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.
>>
> The change seems reasonable (by sight) to me. The problem with
> alignment changes is they can break in unpredictable ways :( But we'll
> see if anyone ever complains I guess.

The alignment does not change in any way.  In case you decrease all your stack 
sizes in your application by 8, then you have roughly the same effect as this 
change.

-- 
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