[PATCH 0/2] Add support for using TLS in Newlib

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Jul 13 09:28:38 UTC 2022


This patch set adds support for the --enable-newlib-reent-thread-local
(_REENT_THREAD_LOCAL_STORAGE) Newlib configuration option.

By default, Newlib uses a huge object of type struct _reent to store
thread-specific data.  This object is returned by __getreent() if the
__DYNAMIC_REENT__ Newlib configuration option is defined.
  
The reentrancy structure contains for example errno and the standard input,
output, and error file streams.  This means that if an application only uses
errno it has a dependency on the file stream support even if it does not use
it.  This is an issue for lower end targets and applications which need to
qualify the software according to safety standards (for example ECSS-E-ST-40C,
ECSS-Q-ST-80C, IEC 61508, ISO 26262, DO-178, DO-330, DO-333).
  
If the new _REENT_THREAD_LOCAL configuration option is enabled, then struct
_reent is replaced by dedicated thread-local objects for each struct _reent
member.  The thread-local objects are defined in translation units which use
the corresponding object.

Matt Joyce (2):
  sptests: Disable Newlib reentrancy
  Support _REENT_THREAD_LOCAL Newlib configuration

 cpukit/include/rtems/confdefs/newlib.h        |  3 +-
 cpukit/include/rtems/confdefs/threads.h       |  6 ++--
 cpukit/include/rtems/libcsupport.h            | 28 +++++++++++--------
 cpukit/include/rtems/score/thread.h           |  4 +++
 cpukit/libcsupport/src/newlibc_reent.c        |  6 ++++
 testsuites/libtests/newlib01/init.c           | 11 +++++---
 testsuites/sptests/sp01/system.h              |  7 +++++
 testsuites/sptests/spstkalloc02/init.c        |  7 +++++
 .../sptests/spstkalloc02/spstkalloc02.doc     |  2 +-
 testsuites/sptests/sptls03/init.c             |  7 +++++
 10 files changed, 62 insertions(+), 19 deletions(-)

-- 
2.35.3



More information about the devel mailing list