summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
authorMatt Joyce <matthew.joyce@embedded-brains.de>2022-05-23 12:27:56 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-07-21 07:22:13 +0200
commit6d4b390f99af0e9d5873a3cb8ebaccfa05cbe37b (patch)
tree69d86bdace4793f3546d387fc00297917c234467 /cpukit/libcsupport
parentsptests: Disable Newlib reentrancy (diff)
downloadrtems-6d4b390f99af0e9d5873a3cb8ebaccfa05cbe37b.tar.bz2
Support _REENT_THREAD_LOCAL Newlib configuration
In case the Newlib _REENT_THREAD_LOCAL configuration option is enabled, the struct _reent is not defined (there is only a forward declaration in <sys/reent.h>). Instead, the usual members of struct _reent are available as dedicatd thread-local storage objects. Update #4560.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r--cpukit/libcsupport/src/getreentglobal.c2
-rw-r--r--cpukit/libcsupport/src/newlibc_reent.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/cpukit/libcsupport/src/getreentglobal.c b/cpukit/libcsupport/src/getreentglobal.c
index 72b513ee81..c64f09ac2c 100644
--- a/cpukit/libcsupport/src/getreentglobal.c
+++ b/cpukit/libcsupport/src/getreentglobal.c
@@ -15,8 +15,10 @@
#if defined(RTEMS_NEWLIB)
#include <sys/reent.h>
+#ifndef _REENT_THREAD_LOCAL
struct _reent *__getreent(void)
{
return _GLOBAL_REENT;
}
#endif
+#endif
diff --git a/cpukit/libcsupport/src/newlibc_reent.c b/cpukit/libcsupport/src/newlibc_reent.c
index 2dccfd0375..ee82f00858 100644
--- a/cpukit/libcsupport/src/newlibc_reent.c
+++ b/cpukit/libcsupport/src/newlibc_reent.c
@@ -29,6 +29,7 @@
#include <rtems/libcsupport.h>
#include <rtems/score/threadimpl.h>
+#ifndef _REENT_THREAD_LOCAL
bool newlib_create_hook(
rtems_tcb *current_task RTEMS_UNUSED,
rtems_tcb *creating_task
@@ -38,12 +39,17 @@ bool newlib_create_hook(
return true;
}
+#endif
void newlib_terminate_hook(
rtems_tcb *current_task
)
{
+#ifdef _REENT_THREAD_LOCAL
+ _reclaim_reent(NULL);
+#else
_reclaim_reent(current_task->libc_reent);
+#endif
}
#endif