xtensa asm2: Fixup stack alignment at runtime

The API allows any byte count for stack size, and tests in fact check
that a stack with a 499 byte stack works correctly.  No choice, have
to do this at runtime.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2017-12-17 12:39:24 -08:00 committed by Anas Nashif
commit 2867bfc1eb

View file

@ -64,7 +64,9 @@ void _new_thread(struct k_thread *thread, k_thread_stack_t *stack, size_t sz,
{
char *base = K_THREAD_STACK_BUFFER(stack);
char *top = base + sz;
__ASSERT((((size_t)top) & 3) == 0, "Misaligned stack");
/* Align downward. The API as specified requires a runtime check. */
top = (char *)(((unsigned int)top) & ~3);
_new_thread_init(thread, base, sz, prio, opts);