[PATCH 3/3] config: Fix CONFIGURE_DISABLE_NEWLIB_REENTRANCY

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Nov 6 12:37:13 UTC 2018


Move the __getreent() variant using the global reentrancy structure to
librtemscpu.a.  This avoids a definition of __getreent() in the
configuration module if CONFIGURE_DISABLE_NEWLIB_REENTRANCY is defined.
This avoids all the dependencies which would be exposed by a reference
to the global reentrancy structure.

This change is only possible since the default configuration moved to
librtemsdefaultconfig.a recently.
---
 cpukit/Makefile.am                      |  1 +
 cpukit/include/rtems/confdefs.h         | 14 +++++---------
 cpukit/libcsupport/src/getreentglobal.c | 26 ++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 9 deletions(-)
 create mode 100644 cpukit/libcsupport/src/getreentglobal.c

diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index b0d9088d44..786222bd81 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -151,6 +151,7 @@ librtemscpu_a_SOURCES += libcsupport/src/__getpid.c
 librtemscpu_a_SOURCES += libcsupport/src/getpid.c
 librtemscpu_a_SOURCES += libcsupport/src/getppid.c
 librtemscpu_a_SOURCES += libcsupport/src/getpwent.c
+librtemscpu_a_SOURCES += libcsupport/src/getreentglobal.c
 librtemscpu_a_SOURCES += libcsupport/src/getrusage.c
 librtemscpu_a_SOURCES += libcsupport/src/__gettod.c
 librtemscpu_a_SOURCES += libcsupport/src/getuid.c
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index 64577b92d7..15d0947ea3 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -2242,15 +2242,11 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
   #define _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS 0
 #endif
 
-#if defined(RTEMS_NEWLIB)
-  struct _reent *__getreent(void)
-  {
-    #ifdef CONFIGURE_DISABLE_NEWLIB_REENTRANCY
-      return _GLOBAL_REENT;
-    #else
-      return _Thread_Get_executing()->libc_reent;
-    #endif
-  }
+#if defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)
+struct _reent *__getreent(void)
+{
+  return _Thread_Get_executing()->libc_reent;
+}
 #endif
 
 #endif
diff --git a/cpukit/libcsupport/src/getreentglobal.c b/cpukit/libcsupport/src/getreentglobal.c
new file mode 100644
index 0000000000..775b4462cc
--- /dev/null
+++ b/cpukit/libcsupport/src/getreentglobal.c
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2018 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if defined(RTEMS_NEWLIB)
+#include <sys/reent.h>
+
+struct _reent *__getreent(void)
+{
+  return _GLOBAL_REENT;
+}
+#endif
-- 
2.16.4




More information about the devel mailing list