[En-Nut-Discussion] CM3 Stack alignment
Harald Kipp
harald.kipp at egnite.de
Mon Sep 23 15:19:26 CEST 2013
Hi Uwe,
a comment line would have been great and help other platform maintainers
to follow. I do have questions.
On 23.09.2013 14:18, bon at elektron.ikp.physik.tu-darmstadt.de wrote:
> for va_arg() to work with double and uint64_t on cortex and arm, the stack
> needs to be aligned on a 8-byte boundary.
You mean the start of stack memory or the current stack pointer value?
While I can imagine, that the latter may be required, I have no idea how
the va_arg() is influenced by the location of the stack's top.
Your patch in nut/arch/cm3/os/context.c does two things:
1. Rounding up the stack size to an 8 byte boundary.
alloc_size = stackSize + sizeof(NUTTHREADINFO);
alloc_size += 7;
alloc_size &= ~7;
Can you explain, why we need to adjust the stack's size?
2. Aligning the stack top to the next lower 8 byte boundary.
td = (NUTTHREADINFO *) (((uint32_t)(threadMem + stackSize)) & ~7);
This will move the initial stack pointer down to the next 8 byte
boundary. But what happens in
void foo(void)
{
int bar;
/* Is my SP still 8-byte aligned here? */
...more code...
}
Regards,
Harald
More information about the En-Nut-Discussion
mailing list