This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] cxxabi.h vs. unwind-cxx.h


In 49818, it's pointed out that none of the EH routines required by
chapter four of the C++ ABI docs are in cxxabi.h. Instead, they are in
unwind-cxx.h. Along with other, GNU-specific implementation items.

Note that the function definitions have always been exported from
the libsupc++/libstdc++ binary. But the declarations have not been in
the required header. 

This conundrum is now fixed with the following patch, which more
cleanly divides the C++ ABI standard from the GNU implementation.
Forward declarations and pointers, solid friends always.

tested x86_64/linux

-benjamin

2011-10-06  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/49818
	* config/abi/pre/gnu.ver (CXXABI_1.3.6): Add symbols.
	* testsuite/util/testsuite_abi.cc: Same.
	* libsupc++/unwind-cxx.h: Move required eh API...
	* libsupc++/cxxabi.h: ... to here. Add required forward declarations.
	* libsupc++/pure.cc (__cxa_deleted_virtual): Add.

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 5e5aa6a..c45b7db 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -104,7 +104,7 @@ GLIBCXX_3.4 {
       std::logic_error*;
       std::locale::[A-Za-e]*;
       std::locale::facet::[A-Za-z]*;
-      std::locale::facet::_S_get_c_locale*;	
+      std::locale::facet::_S_get_c_locale*;
       std::locale::facet::_S_clone_c_locale*;
       std::locale::facet::_S_create_c_locale*;
       std::locale::facet::_S_destroy_c_locale*;
@@ -145,7 +145,7 @@ GLIBCXX_3.4 {
       std::strstream*;
       std::strstreambuf*;
 #     std::t[a-q]*;
-      std::t[a-g]*;      
+      std::t[a-g]*;
       std::th[a-h]*;
       std::th[j-q]*;
       std::th[s-z]*;
@@ -238,7 +238,7 @@ GLIBCXX_3.4 {
     _ZNKSs8_M_limit*;
     _ZNKSs9_M_ibeginEv;
     _ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_E*;
-    _ZNKSs7compare*; 
+    _ZNKSs7compare*;
     _ZNKSs5c_strEv;
     _ZNKSs8capacityEv;
     _ZNKSs4copyEPc[jmy][jmy];
@@ -435,10 +435,10 @@ GLIBCXX_3.4 {
 
     # std::locale destructors
     _ZNSt6localeD*;
-	
+
     # std::locale::facet destructors
     _ZNSt6locale5facetD*;
-	 
+
     # std::locale::_Impl constructors, destructors
     _ZNSt6locale5_ImplC*;
     _ZNSt6locale5_ImplD*;
@@ -447,7 +447,7 @@ GLIBCXX_3.4 {
     _ZNSt8ios_baseD*;
     _ZNSt8ios_base4InitD*;
 
-    # bool std::has_facet 
+    # bool std::has_facet
     _ZSt9has_facetIS*;
 
     # std::use_facet
@@ -486,7 +486,7 @@ GLIBCXX_3.4 {
 
     # std::time_get_byname
     _ZNSt15time_get_byname*;
-    
+
     # std::time_put
     _ZNSt8time_put*;
     _ZNKSt8time_put*;
@@ -569,7 +569,7 @@ GLIBCXX_3.4 {
     _ZNK11__gnu_debug16_Error_formatter13_M_print_word*;
     _ZNK11__gnu_debug16_Error_formatter15_M_print_string*;
     _ZNK11__gnu_debug16_Error_formatter8_M_error*;
-    
+
     # exceptions as functions
     _ZSt16__throw_bad_castv;
     _ZSt17__throw_bad_allocv;
@@ -809,11 +809,11 @@ GLIBCXX_3.4 {
 };
 
 GLIBCXX_3.4.1 {
- 
+
     _ZNSt12__basic_fileIcE4fileEv;
- 
+
 } GLIBCXX_3.4;
- 
+
 GLIBCXX_3.4.2 {
 
     _ZN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EE4fileEv;
@@ -825,7 +825,7 @@ GLIBCXX_3.4.2 {
 } GLIBCXX_3.4.1;
 
 GLIBCXX_3.4.3 {
- 
+
     # stub functions from libmath
     acosf;
     acosl;
@@ -969,7 +969,7 @@ GLIBCXX_3.4.10 {
     _ZNKSt4hashIeEclEe;
 
     _ZSt17__verify_grouping*;
-    
+
     _ZNSt8__detail12__prime_listE;
     _ZNSt3tr18__detail12__prime_listE;
 
@@ -992,7 +992,7 @@ GLIBCXX_3.4.10 {
 } GLIBCXX_3.4.9;
 
 GLIBCXX_3.4.11 {
-	 
+
     # atomic
     __atomic_flag_for_address;
     __atomic_flag_wait_explicit;
@@ -1328,16 +1328,16 @@ CXXABI_1.3 {
     __cxa_rethrow;
     __cxa_throw;
     __cxa_type_match;
+    __cxa_vec_ctor;
     __cxa_vec_cctor;
     __cxa_vec_cleanup;
-    __cxa_vec_ctor;
+    __cxa_vec_delete;
     __cxa_vec_delete2;
     __cxa_vec_delete3;
-    __cxa_vec_delete;
     __cxa_vec_dtor;
+    __cxa_vec_new;
     __cxa_vec_new2;
     __cxa_vec_new3;
-    __cxa_vec_new;
     __gxx_personality_v0;
     __gxx_personality_sj0;
     __dynamic_cast;
@@ -1491,3 +1491,12 @@ CXXABI_1.3.5 {
     _ZTVSt16nested_exception;
 
 } CXXABI_1.3.4;
+
+CXXABI_1.3.6 {
+
+    __cxa_allocate_dependent_exception;
+    __cxa_free_dependent_exception;
+    __cxa_get_exception_ptr;
+    __cxa_deleted_virtual;
+
+} CXXABI_1.3.5;
\ No newline at end of file
diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h
index 0f3856e..3694420 100644
--- a/libstdc++-v3/libsupc++/cxxabi.h
+++ b/libstdc++-v3/libsupc++/cxxabi.h
@@ -54,6 +54,12 @@
 #ifdef __cplusplus
 namespace __cxxabiv1
 {
+  // Forward declarations.
+  struct __cxa_exception;
+  struct __cxa_refcounted_exception;
+  struct __cxa_dependent_exception;
+  struct __cxa_eh_globals;
+
   extern "C"
   {
 #endif
@@ -123,23 +129,72 @@ namespace __cxxabiv1
   void
   __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW;
 
+  // DSO destruction.
+  int
+  __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
+
+  int
+  __cxa_finalize(void*);
+
   // Pure virtual functions.
   void
   __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
 
+  void
+  __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
+
   // Exception handling.
+
+  // The __cxa_eh_globals for the current thread can be obtained by using
+  // either of the following functions.  The "fast" version assumes at least
+  // one prior call of __cxa_get_globals has been made from the current
+  // thread, so no initialization is necessary.
+  __cxa_eh_globals*
+  __cxa_get_globals() throw() __attribute__ ((__const__));
+
+  __cxa_eh_globals*
+  __cxa_get_globals_fast () throw() __attribute__ ((__const__));
+
+  // Allocate memory for the primary exception plus the thrown object.
+  void*
+  __cxa_allocate_exception(std::size_t) throw();
+
+  // Free the space allocated for the primary exception.
+  void 
+  __cxa_free_exception(void*) throw();
+
+  // Allocate memory for a dependent exception.
+  __cxa_dependent_exception*
+  __cxa_allocate_dependent_exception() throw();
+
+  // Free the space allocated for the dependent exception.
   void
-  __cxa_bad_cast();
+  __cxa_free_dependent_exception(__cxa_dependent_exception*) throw();
 
+  // Throw the exception.
   void
-  __cxa_bad_typeid();
+  __cxa_throw(void*, std::type_info*, void (*) (void *)) 
+  __attribute__((__noreturn__));
 
-  // DSO destruction.
-  int
-  __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
+  // Used to implement exception handlers.
+  void*
+  __cxa_get_exception_ptr(void *) throw() __attribute__ ((__pure__));
 
-  int
-  __cxa_finalize(void*);
+  void*
+  __cxa_begin_catch(void *) throw();
+
+  void 
+  __cxa_end_catch();
+
+  void 
+  __cxa_rethrow() __attribute__((__noreturn__));
+
+  // These facilitate code generation for recurring situations.
+  void 
+  __cxa_bad_cast() __attribute__((__noreturn__));
+
+  void 
+  __cxa_bad_typeid() __attribute__((__noreturn__));
 
 
   /**
@@ -185,6 +240,7 @@ namespace __cxxabiv1
   char*
   __cxa_demangle(const char* __mangled_name, char* __output_buffer,
 		 size_t* __length, int* __status);
+
 #ifdef __cplusplus
   }
 } // namespace __cxxabiv1
diff --git a/libstdc++-v3/libsupc++/pure.cc b/libstdc++-v3/libsupc++/pure.cc
index acf7232..4879e59 100644
--- a/libstdc++-v3/libsupc++/pure.cc
+++ b/libstdc++-v3/libsupc++/pure.cc
@@ -1,5 +1,5 @@
 // -*- C++ -*- 
-// Copyright (C) 2000, 2001, 2009 Free Software Foundation
+// Copyright (C) 2000, 2001, 2009, 2011 Free Software Foundation
 //
 // This file is part of GCC.
 //
@@ -49,3 +49,10 @@ __cxxabiv1::__cxa_pure_virtual (void)
   writestr ("pure virtual method called\n");
   std::terminate ();
 }
+
+extern "C" void
+__cxxabiv1::__cxa_deleted_virtual (void)
+{
+  writestr ("deleted virtual method called\n");
+  std::terminate ();
+}
diff --git a/libstdc++-v3/libsupc++/unwind-cxx.h b/libstdc++-v3/libsupc++/unwind-cxx.h
index e62ea7c..84dd367 100644
--- a/libstdc++-v3/libsupc++/unwind-cxx.h
+++ b/libstdc++-v3/libsupc++/unwind-cxx.h
@@ -36,6 +36,7 @@
 #include <cstddef>
 #include "unwind.h"
 #include <bits/atomic_word.h>
+#include <cxxabi.h>
 
 #pragma GCC visibility push(default)
 
@@ -143,47 +144,6 @@ struct __cxa_eh_globals
 #endif
 };
 
-
-// The __cxa_eh_globals for the current thread can be obtained by using
-// either of the following functions.  The "fast" version assumes at least
-// one prior call of __cxa_get_globals has been made from the current
-// thread, so no initialization is necessary.
-extern "C" __cxa_eh_globals *__cxa_get_globals () throw() 
-  __attribute__ ((__const__));
-extern "C" __cxa_eh_globals *__cxa_get_globals_fast () throw() 
-  __attribute__ ((__const__));
-
-// Allocate memory for the primary exception plus the thrown object.
-extern "C" void *__cxa_allocate_exception(std::size_t thrown_size) throw();
-
-// Free the space allocated for the primary exception.
-extern "C" void __cxa_free_exception(void *thrown_exception) throw();
-
-// Allocate memory for a dependent exception.
-extern "C" __cxa_dependent_exception*
-__cxa_allocate_dependent_exception() throw();
-
-// Free the space allocated for the dependent exception.
-extern "C" void
-__cxa_free_dependent_exception(__cxa_dependent_exception *ex) throw();
-
-// Throw the exception.
-extern "C" void __cxa_throw (void *thrown_exception,
-			     std::type_info *tinfo,
-			     void (*dest) (void *))
-  __attribute__((__noreturn__));
-
-// Used to implement exception handlers.
-extern "C" void *__cxa_get_exception_ptr (void *) throw()
-  __attribute__ ((__pure__));
-extern "C" void *__cxa_begin_catch (void *) throw();
-extern "C" void __cxa_end_catch ();
-extern "C" void __cxa_rethrow () __attribute__((__noreturn__));
-
-// These facilitate code generation for recurring situations.
-extern "C" void __cxa_bad_cast () __attribute__((__noreturn__));
-extern "C" void __cxa_bad_typeid () __attribute__((__noreturn__));
-
 // @@@ These are not directly specified by the IA-64 C++ ABI.
 
 // Handles re-checking the exception specification if unexpectedHandler
diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.cc b/libstdc++-v3/testsuite/util/testsuite_abi.cc
index f1f5ad6..9e6837e 100644
--- a/libstdc++-v3/testsuite/util/testsuite_abi.cc
+++ b/libstdc++-v3/testsuite/util/testsuite_abi.cc
@@ -204,6 +204,7 @@ check_version(symbol& test, bool added)
       known_versions.push_back("CXXABI_1.3.3");
       known_versions.push_back("CXXABI_1.3.4");
       known_versions.push_back("CXXABI_1.3.5");
+      known_versions.push_back("CXXABI_1.3.6");
       known_versions.push_back("CXXABI_LDBL_1.3");
     }
   compat_list::iterator begin = known_versions.begin();

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]