[libstdc++] Initialize terminate() handler based on hosted vs freestanding

Phil Edwards phil@jaj.com
Tue Sep 2 18:46:00 GMT 2003


On Sun, Aug 31, 2003 at 01:30:37AM -0400, Phil Edwards wrote:
> 
> I'll check this in later.  Any comments on style/spelling?

Like so.


2003-09-02  Phil Edwards  <phil@codesourcery.com>

	* acinclude.m4 (GLIBCXX_ENABLE_HOSTED):  #define _GLIBCXX_HOSTED
	appropriately.
	* config.h.in:  Add _GLIBCXX_HOSTED.
	* libsupc++/eh_term_handler.cc:  Test it here; initialize
	__terminate_handler to std::abort if freestanding.
	* aclocal.m4, configure:  Regenerated.
	* docs/html/configopts.html:  Document --disable-hosted-libstdcxx.


Index: acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acinclude.m4,v
retrieving revision 1.268
diff -u -3 -p -r1.268 acinclude.m4
--- acinclude.m4	27 Aug 2003 20:26:22 -0000	1.268
+++ acinclude.m4	2 Sep 2003 18:43:44 -0000
@@ -1276,6 +1276,9 @@ dnl
 dnl Sets:
 dnl  is_hosted  (yes/no)
 dnl
+dnl Defines:
+dnl  _GLIBCXX_HOSTED   (always defined, either to 1 or 0)
+dnl
 AC_DEFUN(GLIBCXX_ENABLE_HOSTED, [
   AC_ARG_ENABLE([hosted-libstdcxx],
     AC_HELP_STRING([--disable-hosted-libstdcxx],
@@ -1284,12 +1287,16 @@ AC_DEFUN(GLIBCXX_ENABLE_HOSTED, [
   if test "$enable_hosted_libstdcxx" = no; then
     AC_MSG_NOTICE([Only freestanding libraries will be built])
     is_hosted=no
+    hosted_define=0
     enable_abi_check=no
     enable_libstdcxx_pch=no
   else
     is_hosted=yes
+    hosted_define=1
   fi
   GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes)
+  AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define,
+    [Define to 1 if a full hosted library is built, or 0 if freestanding.])
 ])
 
 
Index: config.h.in
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config.h.in,v
retrieving revision 1.70
diff -u -3 -p -r1.70 config.h.in
--- config.h.in	5 Aug 2003 23:32:20 -0000	1.70
+++ config.h.in	2 Sep 2003 18:43:45 -0000
@@ -878,6 +878,9 @@
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
+/* Define to 1 if a full hosted library is built, or 0 if freestanding. */
+#undef _GLIBCXX_HOSTED
+
 /* Define if the compiler is configured for setjmp/longjmp exceptions. */
 #undef _GLIBCXX_SJLJ_EXCEPTIONS
 //
Index: docs/html/configopts.html
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/docs/html/configopts.html,v
retrieving revision 1.31
diff -u -3 -p -r1.31 configopts.html
--- docs/html/configopts.html	4 Jul 2003 17:36:38 -0000	1.31
+++ docs/html/configopts.html	2 Sep 2003 18:43:49 -0000
@@ -146,7 +146,7 @@ options</a></h1>
 
  <dt><code>--enable-libstdcxx-debug  </code></dt>
  <dd><p>Build separate debug libraries in addition to what is normally built.
- 	By default, the debug libraries are compiled with 
+        By default, the debug libraries are compiled with 
         <code> CXXFLAGS='-g3 -O0'</code>
         , are installed in <code>${libdir}/debug</code>, and have the
         same names and versioning information as the non-debug
@@ -271,6 +271,14 @@ options</a></h1>
         In addition, this generated file is used later on (by appending <code>
         --include bits/stdc++.h </code> to CXXFLAGS) when running the
         testsuite.
+     </p>
+ </dd>
+
+ <dt><code>--disable-hosted-libstdcxx  </code></dt>
+ <dd><p>By default, a complete <em>hosted</em> C++ library is built.  The
+        C++ Standard also describes a <em>freestanding</em> environment,
+        in which only a minimal set of headers are provided.  This option
+        builds such an environment.
      </p>
  </dd>
 </dl>
Index: libsupc++/eh_term_handler.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/eh_term_handler.cc,v
retrieving revision 1.3
diff -u -3 -p -r1.3 eh_term_handler.cc
--- libsupc++/eh_term_handler.cc	24 May 2003 16:22:03 -0000	1.3
+++ libsupc++/eh_term_handler.cc	2 Sep 2003 18:43:50 -0000
@@ -1,5 +1,5 @@
 // -*- C++ -*- std::terminate handler
-// Copyright (C) 2002 Free Software Foundation
+// Copyright (C) 2002, 2003 Free Software Foundation
 //
 // This file is part of GCC.
 //
@@ -28,14 +28,24 @@
 // the GNU General Public License.
 
 #include "unwind-cxx.h"
+#include <bits/c++config.h>
 
-/* We default to the talkative, informative handler.  This pulls in the
-   demangler, the dyn-string utilities, and elements of the I/O library.
-   For a low-memory environment, you can return to the earlier "silent death"
-   handler by including <cstdlib>, initializg to "std::abort", and rebuilding
-   the library.  */
+/* We default to the talkative, informative handler in a normal hosted
+   library.  This pulls in the demangler, the dyn-string utilities, and
+   elements of the I/O library.  For a low-memory environment, you can return
+   to the earlier "silent death" handler by including <cstdlib>, initializing
+   to "std::abort", and rebuilding the library.  In a freestanding mode, we
+   default to this latter approach.  */
+
+#if ! _GLIBCXX_HOSTED
+# include <cstdlib>
+#endif
 
 /* The current installed user handler.  */
 std::terminate_handler __cxxabiv1::__terminate_handler =
-                                       __gnu_cxx::__verbose_terminate_handler;
+#if _GLIBCXX_HOSTED
+	__gnu_cxx::__verbose_terminate_handler;
+#else
+	std::abort;
+#endif
 



More information about the Libstdc++ mailing list