From ea99f21ce6c8a332845439ea87f792dbaf679d42 Mon Sep 17 00:00:00 2001 From: Matt Joyce Date: Mon, 16 May 2022 11:51:54 +0200 Subject: 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. --- newlib/libc/stdlib/mblen.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'newlib/libc/stdlib/mblen.c') diff --git a/newlib/libc/stdlib/mblen.c b/newlib/libc/stdlib/mblen.c index 3753d36..24df615 100644 --- a/newlib/libc/stdlib/mblen.c +++ b/newlib/libc/stdlib/mblen.c @@ -42,6 +42,10 @@ effects vary with the locale. #include #include "local.h" +#ifdef _REENT_THREAD_LOCAL +_Thread_local _mbstate_t _tls_mblen_state; +#endif + int mblen (const char *s, size_t n) -- cgit v1.1