diff options
author | Matt Joyce <matthew.joyce@embedded-brains.de> | 2022-05-16 12:51:54 +0300 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2022-07-13 07:55:46 +0300 |
commit | ea99f21ce6c8a332845439ea87f792dbaf679d42 (patch) | |
tree | 94cfcaf461882955f7461b09d6c4c0e2f321e66e /newlib/libc/reent | |
parent | 1a0908203606527b6ac0ed438669b5bcd247a5f9 (diff) |
Add --enable-newlib-reent-thread-local 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.
Diffstat (limited to 'newlib/libc/reent')
-rw-r--r-- | newlib/libc/reent/impure.c | 4 | ||||
-rw-r--r-- | newlib/libc/reent/reent.c | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/newlib/libc/reent/impure.c b/newlib/libc/reent/impure.c index 9290c9cd5..a87b91feb 100644 --- a/newlib/libc/reent/impure.c +++ b/newlib/libc/reent/impure.c @@ -1,5 +1,7 @@ #include <reent.h> +#ifndef _REENT_THREAD_LOCAL + /* Redeclare these symbols locally as weak so that the file containing their definitions (along with a lot of other stuff) isn't sucked in unless they are actually used by other compilation units. This is @@ -14,3 +16,5 @@ struct _reent __ATTRIBUTE_IMPURE_DATA__ _impure_data = _REENT_INIT (_impure_data extern struct _reent reent_data __attribute__ ((alias("_impure_data"))); #endif struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr = &_impure_data; + +#endif /* _REENT_THREAD_LOCAL */ diff --git a/newlib/libc/reent/reent.c b/newlib/libc/reent/reent.c index 4e9485c7a..db80ca06e 100644 --- a/newlib/libc/reent/reent.c +++ b/newlib/libc/reent/reent.c @@ -30,7 +30,9 @@ int errno; void _reclaim_reent (struct _reent *ptr) { +#ifndef _REENT_THREAD_LOCAL if (ptr != _impure_ptr) +#endif { /* used by mprec routines. */ #ifdef _REENT_SMALL |