[PATCH 09/21] score: Add _Stack_Extend_size()
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Dec 16 14:28:14 UTC 2019
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 aafde5d1a0..305c4e4e51 100644
--- a/cpukit/include/rtems/score/stackimpl.h
+++ b/cpukit/include/rtems/score/stackimpl.h
@@ -120,6 +120,33 @@ RTEMS_INLINE_ROUTINE size_t _Stack_Ensure_minimum (
return _Stack_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.
*
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index cf21602ac0..a2bb09425d 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;
--
2.16.4
More information about the devel
mailing list