[rtems commit] score: Fix TLS size usage

Sebastian Huber sebh at rtems.org
Mon May 5 07:36:18 UTC 2014


Module:    rtems
Branch:    master
Commit:    bee71f8e97739cfb2b272cbf5c4822c634b7cac7
Changeset: http://git.rtems.org/rtems/commit/?id=bee71f8e97739cfb2b272cbf5c4822c634b7cac7

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Apr 30 14:54:58 2014 +0200

score: Fix TLS size usage

---

 cpukit/score/include/rtems/score/tls.h |    9 +++++++++
 cpukit/score/src/threadinitialize.c    |    7 +------
 cpukit/score/src/wkspace.c             |    2 +-
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/cpukit/score/include/rtems/score/tls.h b/cpukit/score/include/rtems/score/tls.h
index f9abc27..139db78 100644
--- a/cpukit/score/include/rtems/score/tls.h
+++ b/cpukit/score/include/rtems/score/tls.h
@@ -80,6 +80,15 @@ typedef struct {
   uintptr_t offset;
 } TLS_Index;
 
+static inline uintptr_t _TLS_Get_size( void )
+{
+  /*
+   * Do not use _TLS_Size here since this will lead GCC to assume that this
+   * symbol is not 0 and the tests for 0 will be optimized away.
+   */
+  return (uintptr_t) _TLS_BSS_end - (uintptr_t) _TLS_Data_begin;
+}
+
 static inline uintptr_t _TLS_Heap_align_up( uintptr_t val )
 {
   uintptr_t msk = CPU_HEAP_ALIGNMENT - 1;
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index f8e0e7d..fb3d6c8 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -43,6 +43,7 @@ bool _Thread_Initialize(
   Objects_Name                          name
 )
 {
+  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 )
@@ -52,12 +53,6 @@ bool _Thread_Initialize(
   size_t                   i;
   bool                     scheduler_allocated = false;
 
-  /*
-   * Do not use _TLS_Size here since this will lead GCC to assume that this
-   * symbol is not 0 and the later > 0 test will be optimized away.
-   */
-  uintptr_t  tls_size = (uintptr_t) _TLS_BSS_end - (uintptr_t) _TLS_Data_begin;
-
 #if defined( RTEMS_SMP )
   if ( rtems_configuration_is_smp_enabled() && !is_preemptible ) {
     return false;
diff --git a/cpukit/score/src/wkspace.c b/cpukit/score/src/wkspace.c
index 20e2563..1dda9f1 100644
--- a/cpukit/score/src/wkspace.c
+++ b/cpukit/score/src/wkspace.c
@@ -63,7 +63,7 @@ void _Workspace_Handler_initialization(
   bool unified = rtems_configuration_get_unified_work_area();
   uintptr_t page_size = CPU_HEAP_ALIGNMENT;
   uintptr_t overhead = _Heap_Area_overhead( page_size );
-  uintptr_t tls_size = (uintptr_t) _TLS_Size;
+  uintptr_t tls_size = _TLS_Get_size();
   size_t i;
 
   if ( tls_size > 0 ) {




More information about the vc mailing list