[PATCH 2/3] score: Changes due to Newlib __DYNAMIC_REENT__

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Jul 8 13:25:01 UTC 2013


Delete _Thread_libc_reent and add __getreent() instead.
---
 cpukit/libcsupport/src/newlibc_reent.c     |    7 -------
 cpukit/sapi/include/confdefs.h             |   16 ++++++++++++++--
 cpukit/score/include/rtems/score/thread.h  |    7 -------
 cpukit/score/inline/rtems/score/thread.inl |   20 --------------------
 cpukit/score/src/threaddispatch.c          |    8 --------
 5 files changed, 14 insertions(+), 44 deletions(-)

diff --git a/cpukit/libcsupport/src/newlibc_reent.c b/cpukit/libcsupport/src/newlibc_reent.c
index 972248f..8640089 100644
--- a/cpukit/libcsupport/src/newlibc_reent.c
+++ b/cpukit/libcsupport/src/newlibc_reent.c
@@ -36,13 +36,6 @@ bool newlib_create_hook(
   struct _reent *ptr;
   bool ok;
 
-  if (_Thread_libc_reent == 0)
-  {
-    _REENT = _GLOBAL_REENT;
-
-    _Thread_Set_libc_reent (&_REENT);
-  }
-
   /* It is OK to allocate from the workspace because these
    * hooks run with thread dispatching disabled.
    */
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index bf9f5e8..a5a583b 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -61,6 +61,10 @@
   #include <bsp.h>
 #endif
 
+#ifdef RTEMS_NEWLIB
+  #include <sys/reent.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -1650,6 +1654,16 @@ const rtems_libio_helper rtems_fs_init_helper =
   #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS 0
 #endif
 
+#ifdef RTEMS_NEWLIB
+  struct _reent *__getreent(void)
+  {
+    #ifdef CONFIGURE_DISABLE_NEWLIB_REENTRANCY
+      return _GLOBAL_REENT;
+    #else
+      return _Thread_Executing->libc_reent;
+    #endif
+  }
+#endif
 
 #endif
 
@@ -1939,8 +1953,6 @@ const rtems_libio_helper rtems_fs_init_helper =
  */
 
 #if (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY))
-  #include <reent.h>
-
   #define CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB \
     _Configure_From_workspace(sizeof(struct _reent))
 #else
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 13b7e75..c08ad11 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -499,13 +499,6 @@ SCORE_EXTERN Thread_Control *_Thread_Allocated_fp;
 #endif
 
 /**
- * The C library re-enter-rant global pointer. Some C library implementations
- * such as newlib have a single global pointer that changed during a context
- * switch. The pointer points to that global pointer. The Thread control block
- * holds a pointer to the task specific data.
- */
-SCORE_EXTERN struct _reent **_Thread_libc_reent;
-/**
  *  @brief Initialize thread handler.
  *
  *  This routine performs the initialization necessary for this handler.
diff --git a/cpukit/score/inline/rtems/score/thread.inl b/cpukit/score/inline/rtems/score/thread.inl
index 4576dea..0561944 100644
--- a/cpukit/score/inline/rtems/score/thread.inl
+++ b/cpukit/score/inline/rtems/score/thread.inl
@@ -248,26 +248,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Dispatch_if_necessary(
   }
 }
 
-/**
- * This routine returns the C library re-enterant pointer.
- */
-
-RTEMS_INLINE_ROUTINE struct _reent **_Thread_Get_libc_reent( void )
-{
-  return _Thread_libc_reent;
-}
-
-/**
- * This routine set the C library re-enterant pointer.
- */
-
-RTEMS_INLINE_ROUTINE void _Thread_Set_libc_reent (
-  struct _reent **libc_reent
-)
-{
-  _Thread_libc_reent = libc_reent;
-}
-
 /** @}*/
 
 #endif
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
index 4cd449d..7000220 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -143,14 +143,6 @@ void _Thread_Dispatch( void )
       }
     #endif
 
-    /*
-     * Switch libc's task specific data.
-     */
-    if ( _Thread_libc_reent ) {
-      executing->libc_reent = *_Thread_libc_reent;
-      *_Thread_libc_reent = heir->libc_reent;
-    }
-
     _User_extensions_Thread_switch( executing, heir );
 
     /*
-- 
1.7.7




More information about the devel mailing list