summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-12-07 16:00:58 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-02-12 09:08:35 +0100
commita0211fc9f9883d0a1182548de11ab0e0505a81c6 (patch)
treef7f5ffa7f53492d54100185e5343d9d55dba72fd /cpukit/score
parentscore: Remove superfluous FP types/defines (diff)
downloadrtems-a0211fc9f9883d0a1182548de11ab0e0505a81c6.tar.bz2
score: Simplify thread stack allocation
Remove superfluous Thread_Control::Start::stack member. Update #3835.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/src/threadinitialize.c29
-rw-r--r--cpukit/score/src/threadstackallocate.c28
2 files changed, 19 insertions, 38 deletions
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 83c689eee4..3b04ed26ab 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -43,8 +43,6 @@ bool _Thread_Initialize(
)
{
uintptr_t tls_size = _TLS_Get_size();
- size_t actual_stack_size = 0;
- void *stack = NULL;
#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
void *fp_area = NULL;
#endif
@@ -92,30 +90,31 @@ bool _Thread_Initialize(
* Allocate and Initialize the stack for this thread.
*/
#if !defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API)
- actual_stack_size = _Thread_Stack_Allocate( the_thread, stack_size );
- if ( !actual_stack_size || actual_stack_size < stack_size )
- return false; /* stack allocation failed */
+ stack_size = _Stack_Ensure_minimum( stack_size );
+ stack_area = _Stack_Allocate( stack_size );
- stack = the_thread->Start.stack;
+ if ( stack_area == NULL ) {
+ return false;
+ }
#else
- if ( !stack_area ) {
- actual_stack_size = _Thread_Stack_Allocate( the_thread, stack_size );
- if ( !actual_stack_size || actual_stack_size < stack_size )
- return false; /* stack allocation failed */
+ if ( stack_area == NULL ) {
+ stack_size = _Stack_Ensure_minimum( stack_size );
+ stack_area = _Stack_Allocate( stack_size );
+
+ if ( stack_area == NULL ) {
+ return false;
+ }
- stack = the_thread->Start.stack;
the_thread->Start.core_allocated_stack = true;
} else {
- stack = stack_area;
- actual_stack_size = stack_size;
the_thread->Start.core_allocated_stack = false;
}
#endif
_Stack_Initialize(
&the_thread->Start.Initial_stack,
- stack,
- actual_stack_size
+ stack_area,
+ stack_size
);
scheduler_index = 0;
diff --git a/cpukit/score/src/threadstackallocate.c b/cpukit/score/src/threadstackallocate.c
index fd89d7f07f..722de7bfd6 100644
--- a/cpukit/score/src/threadstackallocate.c
+++ b/cpukit/score/src/threadstackallocate.c
@@ -1,11 +1,11 @@
/**
* @file
- *
+ *
+ * @ingroup RTEMSScoreStack
+ *
* @brief Stack Allocate Helper
- * @ingroup RTEMSScoreThread
*/
-
/*
* COPYRIGHT (c) 1989-2010.
* On-Line Applications Research Corporation (OAR).
@@ -19,28 +19,10 @@
#include "config.h"
#endif
-#include <rtems/score/threadimpl.h>
#include <rtems/score/stackimpl.h>
#include <rtems/config.h>
-size_t _Thread_Stack_Allocate(
- Thread_Control *the_thread,
- size_t stack_size
-)
+void *_Stack_Allocate( size_t stack_size )
{
- void *stack_addr = 0;
- size_t the_stack_size;
- rtems_stack_allocate_hook stack_allocate_hook =
- rtems_configuration_get_stack_allocate_hook();
-
- the_stack_size = _Stack_Ensure_minimum( stack_size );
-
- stack_addr = (*stack_allocate_hook)( the_stack_size );
-
- if ( !stack_addr )
- the_stack_size = 0;
-
- the_thread->Start.stack = stack_addr;
-
- return the_stack_size;
+ return ( *rtems_configuration_get_stack_allocate_hook() )( stack_size );
}