[rtems commit] score: Add _Stack_Extend_size()
Sebastian Huber
sebh at rtems.org
Wed Feb 12 15:11:59 UTC 2020
Module: rtems
Branch: master
Commit: 4c9deb6c10ad2ccab37da5723748841dbc73f0d2
Changeset: http://git.rtems.org/rtems/commit/?id=4c9deb6c10ad2ccab37da5723748841dbc73f0d2
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Dec 9 14:33:06 2019 +0100
score: Add _Stack_Extend_size()
Update #3835.
---
cpukit/include/rtems/score/stackimpl.h | 27 +++++++++++++++++++++++++++
cpukit/score/src/threadinitialize.c | 13 +++----------
2 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/cpukit/include/rtems/score/stackimpl.h b/cpukit/include/rtems/score/stackimpl.h
index aafde5d..305c4e4 100644
--- a/cpukit/include/rtems/score/stackimpl.h
+++ b/cpukit/include/rtems/score/stackimpl.h
@@ -121,6 +121,33 @@ RTEMS_INLINE_ROUTINE size_t _Stack_Ensure_minimum (
}
/**
+ * @brief Extend the stack size to account for additional data structures
+ * allocated in the stack area of a thread.
+ *
+ * @param stack_size The stack size.
+ * @param is_fp Indicates if the stack is for a floating-point thread.
+ *
+ * @return The extended stack size.
+ */
+RTEMS_INLINE_ROUTINE size_t _Stack_Extend_size(
+ size_t stack_size,
+ bool is_fp
+)
+{
+#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
+ if ( is_fp ) {
+ stack_size += CONTEXT_FP_SIZE;
+ }
+#else
+ (void) is_fp;
+#endif
+
+ stack_size += _TLS_Get_allocation_size();
+
+ return stack_size;
+}
+
+/**
* @brief Allocate the requested stack space.
*
* @param stack_size The stack space that is requested.
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index cf21602..a2bb094 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -76,21 +76,12 @@ bool _Thread_Initialize(
(char *) the_thread + add_on->source_offset;
}
- tls_size = _TLS_Get_allocation_size();
-
/* Allocate the stack for this thread */
#if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API)
if ( config->stack_area == NULL ) {
#endif
stack_size = _Stack_Ensure_minimum( config->stack_size );
-
-#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
- if ( config->is_fp ) {
- stack_size += CONTEXT_FP_SIZE;
- }
-#endif
-
- stack_size += tls_size;
+ stack_size = _Stack_Extend_size( stack_size, config->is_fp );
stack_area = _Stack_Allocate( stack_size );
if ( stack_area == NULL ) {
@@ -115,6 +106,8 @@ bool _Thread_Initialize(
}
#endif
+ tls_size = _TLS_Get_allocation_size();
+
/* Allocate thread-local storage (TLS) area in stack area */
if ( tls_size > 0 ) {
uintptr_t tls_align;
More information about the vc
mailing list