kernel: add Z_STACK_PTR_ALIGN ARCH_STACK_PTR_ALIGN

This operation is formally defined as rounding down a potential
stack pointer value to meet CPU and ABI requirments.

This was previously defined ad-hoc as STACK_ROUND_DOWN().

A new architecture constant ARCH_STACK_PTR_ALIGN is added.
Z_STACK_PTR_ALIGN() is defined in terms of it. This used to
be inconsistently specified as STACK_ALIGN or STACK_PTR_ALIGN;
in the latter case, STACK_ALIGN meant something else, typically
a required alignment for the base of a stack buffer.

STACK_ROUND_UP() only used in practice by Risc-V, delete
elsewhere.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-04-19 15:06:31 -07:00 committed by Anas Nashif
commit 618426d6e7
30 changed files with 69 additions and 87 deletions

View file

@ -25,7 +25,7 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
/* Initial stack frame for thread */
stack_init = (struct __esf *)
STACK_ROUND_DOWN(stack_memory +
Z_STACK_PTR_ALIGN(stack_memory +
stack_size - sizeof(struct __esf));
/* Setup the initial stack frame */