summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--cpukit/include/rtems/score/stackimpl.h10
-rw-r--r--cpukit/include/rtems/score/thread.h2
-rw-r--r--cpukit/include/rtems/score/threadimpl.h17
-rw-r--r--cpukit/score/src/threadinitialize.c29
-rw-r--r--cpukit/score/src/threadstackallocate.c28
5 files changed, 29 insertions, 57 deletions
diff --git a/cpukit/include/rtems/score/stackimpl.h b/cpukit/include/rtems/score/stackimpl.h
index 98eda3148a..6b14560c9b 100644
--- a/cpukit/include/rtems/score/stackimpl.h
+++ b/cpukit/include/rtems/score/stackimpl.h
@@ -105,6 +105,16 @@ RTEMS_INLINE_ROUTINE size_t _Stack_Ensure_minimum (
return _Stack_Minimum();
}
+/**
+ * @brief Allocate the requested stack space.
+ *
+ * @param stack_size The stack space that is requested.
+ *
+ * @retval stack_area The allocated stack area.
+ * @retval NULL The allocation failed.
+ */
+void *_Stack_Allocate( size_t stack_size );
+
/** @} */
#ifdef __cplusplus
diff --git a/cpukit/include/rtems/score/thread.h b/cpukit/include/rtems/score/thread.h
index bd8de4ef81..5c62efc1f7 100644
--- a/cpukit/include/rtems/score/thread.h
+++ b/cpukit/include/rtems/score/thread.h
@@ -209,8 +209,6 @@ typedef struct {
/** This field is the initial FP context area address. */
Context_Control_fp *fp_context;
#endif
- /** This field is the initial stack area address. */
- void *stack;
/** The thread-local storage (TLS) area */
void *tls_area;
} Thread_Start_information;
diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h
index 6989bebc34..3ff6c94777 100644
--- a/cpukit/include/rtems/score/threadimpl.h
+++ b/cpukit/include/rtems/score/threadimpl.h
@@ -125,23 +125,6 @@ void _Thread_Create_idle(void);
void _Thread_Start_multitasking( void ) RTEMS_NO_RETURN;
/**
- * @brief Allocates the requested stack space for the thread.
- *
- * Allocate the requested stack space for the thread.
- * Set the Start.stack field to the address of the stack.
- *
- * @param[out] the_thread The thread where the stack space is requested.
- * @param stack_size The stack space that is requested.
- *
- * @retval actual Size allocated after any adjustment.
- * @retval zero The allocation failed.
- */
-size_t _Thread_Stack_Allocate(
- Thread_Control *the_thread,
- size_t stack_size
-);
-
-/**
* @brief Deallocates thread stack.
*
* Deallocate the Thread's stack.
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 );
}