[rtems commit] libcsupport/newlib: Call newlib' s __sinit to force reent initialisation
Chris Johns
chrisj at rtems.org
Thu Feb 20 01:20:59 UTC 2020
Module: rtems
Branch: 4.11
Commit: fe09d8d4d3c8c663217be1d1db49fb579bfdadbe
Changeset: http://git.rtems.org/rtems/commit/?id=fe09d8d4d3c8c663217be1d1db49fb579bfdadbe
Author: Chris Johns <chrisj at rtems.org>
Date: Fri Feb 14 15:16:46 2020 +1100
libcsupport/newlib: Call newlib's __sinit to force reent initialisation
- Newlib overtites any FILE pointers set in stdin, stdout or stderr.
Closes #3870
---
cpukit/libcsupport/src/newlibc_reent.c | 5 ++++-
testsuites/libtests/newlib01/init.c | 8 ++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/cpukit/libcsupport/src/newlibc_reent.c b/cpukit/libcsupport/src/newlibc_reent.c
index 430157c..6dc0b1e 100644
--- a/cpukit/libcsupport/src/newlibc_reent.c
+++ b/cpukit/libcsupport/src/newlibc_reent.c
@@ -44,7 +44,10 @@ bool newlib_create_hook(
}
#endif
- _REENT_INIT_PTR((creating_task->libc_reent)); /* GCC extension: structure constants */
+ extern void __sinit (struct _reent *s);
+ struct _reent *reent = (struct _reent *) creating_task->libc_reent;
+ _REENT_INIT_PTR((reent)); /* GCC extension: structure constants */
+ __sinit( reent );
return true;
}
diff --git a/testsuites/libtests/newlib01/init.c b/testsuites/libtests/newlib01/init.c
index f9d3936..a8e5b39 100644
--- a/testsuites/libtests/newlib01/init.c
+++ b/testsuites/libtests/newlib01/init.c
@@ -245,6 +245,10 @@ static void test(void)
int rv;
rtems_resource_snapshot snapshot;
+ rtems_test_assert(fileno(stdout) >= 0);
+ rtems_test_assert(fileno(stdin) >= 0);
+ rtems_test_assert(fileno(stderr) >= 0);
+
ctx->main_task_id = rtems_task_self();
rtems_resource_snapshot_take(&snapshot);
@@ -275,6 +279,10 @@ static void test(void)
sc = rtems_task_delete(ctx->worker_task_id);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+ rtems_test_assert(fileno(stdout) >= 0);
+ rtems_test_assert(fileno(stdin) >= 0);
+ rtems_test_assert(fileno(stderr) >= 0);
+
rv = unlink(&file_path[0]);
rtems_test_assert(rv == 0);
More information about the vc
mailing list