From 9c9b62d8ddc9d61abad5106b819bb3ca9912d572 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 17 Jul 2013 11:44:55 +0200 Subject: score: Changes due to Newlib __DYNAMIC_REENT__ Delete _Thread_libc_reent and add __getreent() instead according to __DYNAMIC_REENT__ define. For SMP configurations __DYNAMIC_REENT__ must be defined. A Newlib including the following patch is required: 2013-07-09 Sebastian Huber * libc/include/sys/config.h (__DYNAMIC_REENT__): Define for RTEMS. --- cpukit/libcsupport/src/newlibc_reent.c | 2 ++ cpukit/sapi/include/confdefs.h | 16 ++++++++++++++-- cpukit/score/include/rtems/score/thread.h | 3 +++ cpukit/score/inline/rtems/score/thread.inl | 2 ++ cpukit/score/src/threaddispatch.c | 2 ++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cpukit/libcsupport/src/newlibc_reent.c b/cpukit/libcsupport/src/newlibc_reent.c index 972248fa67..62b5d6b123 100644 --- a/cpukit/libcsupport/src/newlibc_reent.c +++ b/cpukit/libcsupport/src/newlibc_reent.c @@ -36,12 +36,14 @@ bool newlib_create_hook( struct _reent *ptr; bool ok; +#if !defined(__DYNAMIC_REENT__) if (_Thread_libc_reent == 0) { _REENT = _GLOBAL_REENT; _Thread_Set_libc_reent (&_REENT); } +#endif /* 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 bf9f5e8d6f..1585548e7c 100644 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -61,6 +61,10 @@ #include #endif +#ifdef RTEMS_NEWLIB + #include +#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 +#if defined(RTEMS_NEWLIB) && defined(__DYNAMIC_REENT__) + struct _reent *__getreent(void) + { + #ifdef CONFIGURE_DISABLE_NEWLIB_REENTRANCY + return _GLOBAL_REENT; + #else + return _Thread_Get_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 - #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 5e8bc950a7..9ce8ad1fd1 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -499,6 +499,7 @@ SCORE_EXTERN uint32_t _Thread_Ticks_per_timeslice; SCORE_EXTERN Thread_Control *_Thread_Allocated_fp; #endif +#if !defined(__DYNAMIC_REENT__) /** * 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 @@ -506,6 +507,8 @@ SCORE_EXTERN Thread_Control *_Thread_Allocated_fp; * holds a pointer to the task specific data. */ SCORE_EXTERN struct _reent **_Thread_libc_reent; +#endif + /** * @brief Initialize thread handler. * diff --git a/cpukit/score/inline/rtems/score/thread.inl b/cpukit/score/inline/rtems/score/thread.inl index 4576dea79e..88438d66bc 100644 --- a/cpukit/score/inline/rtems/score/thread.inl +++ b/cpukit/score/inline/rtems/score/thread.inl @@ -248,6 +248,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Dispatch_if_necessary( } } +#if !defined(__DYNAMIC_REENT__) /** * This routine returns the C library re-enterant pointer. */ @@ -267,6 +268,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Set_libc_reent ( { _Thread_libc_reent = libc_reent; } +#endif /** @}*/ diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c index 4cd449d55b..adce3a18d3 100644 --- a/cpukit/score/src/threaddispatch.c +++ b/cpukit/score/src/threaddispatch.c @@ -143,6 +143,7 @@ void _Thread_Dispatch( void ) } #endif +#if !defined(__DYNAMIC_REENT__) /* * Switch libc's task specific data. */ @@ -150,6 +151,7 @@ void _Thread_Dispatch( void ) executing->libc_reent = *_Thread_libc_reent; *_Thread_libc_reent = heir->libc_reent; } +#endif _User_extensions_Thread_switch( executing, heir ); -- cgit v1.2.3