Bugfix: Enforce initial stack alignment

This commit is contained in:
Tido Klaassen
2015-07-19 18:54:29 +02:00
parent f6ee11c088
commit 05329c53e3
2 changed files with 9 additions and 0 deletions

View File

@@ -143,6 +143,11 @@ void archThreadContextInit(ATOM_TCB *tcb_ptr, void *stack_top,
struct isr_stack *isr_ctx;
struct task_stack *tsk_ctx;
/**
* Enforce initial stack alignment
*/
stack_top = STACK_ALIGN(stack_top, STACK_ALIGN_SIZE);
/**
* New threads will be scheduled from an exception handler, so we have to
* set up an exception stack frame as well as task stack frame

View File

@@ -40,6 +40,10 @@
/* Size of each stack entry / stack alignment size (4 bytes on Cortex-M without FPU) */
#define STACK_ALIGN_SIZE sizeof(uint32_t)
#define ALIGN(x, a) ((x + (typeof(x))(a) - 1) & ~((typeof(x))(a) - 1))
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((uint32_t)(p), (a)))
#define STACK_ALIGN(p, a) (typeof(p))((typeof(a))(p) & ~((a) - 1))
#define POINTER void *
#define UINT32 uint32_t