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/configure | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'newlib/configure') diff --git a/newlib/configure b/newlib/configure index 82c256694..e493eb293 100755 --- a/newlib/configure +++ b/newlib/configure @@ -973,6 +973,7 @@ enable_newlib_atexit_dynamic_alloc enable_newlib_global_atexit enable_newlib_reent_small enable_newlib_reent_binary_compat +enable_newlib_reent_thread_local enable_newlib_global_stdio_streams enable_newlib_fvwrite_in_streamio enable_newlib_fseek_optimization @@ -1641,6 +1642,7 @@ Optional Features: --enable-newlib-global-atexit enable atexit data structure as global --enable-newlib-reent-small enable small reentrant struct support --enable-newlib-reent-binary-compat enable backward binary compatibility for struct _reent + --enable-newlib-reent-thread-local enable thread-local storage objects as a replacment for struct _reent members --enable-newlib-global-stdio-streams enable global stdio streams --disable-newlib-fvwrite-in-streamio disable iov in streamio --disable-newlib-fseek-optimization disable fseek optimization @@ -2404,6 +2406,19 @@ else newlib_reent_binary_compat=no fi +# Check whether --enable-newlib-reent-thread-local was given. +if test "${enable_newlib_reent_thread_local+set}" = set; then : + enableval=$enable_newlib_reent_thread_local; if test "${newlib_reent_thread_local+set}" != set; then + case "${enableval}" in + yes) newlib_reent_thread_local=yes ;; + no) newlib_reent_thread_local=no ;; + *) as_fn_error $? "bad value ${enableval} for newlib-enable-reent-thread-local option" "$LINENO" 5 ;; + esac + fi +else + newlib_reent_thread_local=no +fi + # Check whether --enable-newlib-global-stdio-streams was given. if test "${enable_newlib_global_stdio_streams+set}" = set; then : enableval=$enable_newlib_global_stdio_streams; case "${enableval}" in @@ -6437,6 +6452,12 @@ $as_echo "#define _WANT_REENT_BACKWARD_BINARY_COMPAT 1" >>confdefs.h fi +if test "${newlib_reent_thread_local}" = "yes"; then + +$as_echo "#define _WANT_REENT_THREAD_LOCAL 1" >>confdefs.h + +fi + _mb_len_max=1 if test "${newlib_mb}" = "yes"; then -- cgit v1.2.3