diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-03-03 09:23:20 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-03-05 06:58:33 +0100 |
commit | 524839568d8df72bb3d62d64cb1b927bc8dbbbf1 (patch) | |
tree | 1a448dc50f597a98e52f3fb13f705b34bb6ee9ad /cpukit/score/src/threadinitialize.c | |
parent | CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE (diff) | |
download | rtems-524839568d8df72bb3d62d64cb1b927bc8dbbbf1.tar.bz2 |
score: Ensure stack alignment requirement
Make sure that a user-provided stack size is the minimum size allocated
for the stack.
Make sure we meet the stack alignment requirement also for CPU ports
with CPU_STACK_ALIGNMENT > CPU_HEAP_ALIGNMENT.
Diffstat (limited to 'cpukit/score/src/threadinitialize.c')
-rw-r--r-- | cpukit/score/src/threadinitialize.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index 3a331ed269..f11e35dcf3 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -107,6 +107,7 @@ static bool _Thread_Try_initialize( size_t i; char *stack_begin; char *stack_end; + uintptr_t stack_align; Scheduler_Node *scheduler_node; #if defined(RTEMS_SMP) Scheduler_Node *scheduler_node_for_index; @@ -128,8 +129,12 @@ static bool _Thread_Try_initialize( (char *) the_thread + add_on->source_offset; } + /* Set up the properly aligned stack area begin and end */ stack_begin = config->stack_area; stack_end = stack_begin + config->stack_size; + stack_align = CPU_STACK_ALIGNMENT; + stack_begin = (char *) RTEMS_ALIGN_UP( (uintptr_t) stack_begin, stack_align ); + stack_end = (char *) RTEMS_ALIGN_DOWN( (uintptr_t) stack_end, stack_align ); /* Allocate floating-point context in stack area */ #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |