mirror of
https://github.com/kelvinlawson/atomthreads.git
synced 2026-01-12 02:43:15 +01:00
Bugfix: Enforce initial stack alignment
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user