diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-02-25 20:52:31 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-02-26 08:57:08 +0100 |
commit | 069506bcb0ee4005b01c22095ed427b96b553c98 (patch) | |
tree | 96e05c9acb45071dbde1fff19bbef4c587487994 | |
parent | 128deeae81a6f802bfb79b8f0fa8c4b10729f7db (diff) |
Use config_cxxabi.h to check for __cxa_eh_globals, __cxa_exception
Change-Id: I467341da4bccb3afb82518b444cd101b3cdaacc9
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx | 4 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx | 65 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx | 10 | ||||
-rw-r--r-- | config_host/config_cxxabi.h.in | 2 | ||||
-rw-r--r-- | configure.ac | 24 |
5 files changed, 53 insertions, 52 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx index 5efd7cb752e8..04d13e80c748 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx @@ -81,7 +81,7 @@ static OUString toUNOname( char const * p ) extern "C" { static void _GLIBCXX_CDTOR_CALLABI deleteException( void * pExc ) { - __cxa_exception const * header = (static_cast<__cxa_exception const *>(pExc) - 1); + __cxxabiv1::__cxa_exception const * header = (static_cast<__cxxabiv1::__cxa_exception const *>(pExc) - 1); typelib_TypeDescription * pTD = nullptr; OUString unoName( toUNOname( header->exceptionType->name() ) ); ::typelib_typedescription_getByName( &pTD, unoName.pData ); @@ -138,7 +138,7 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) __cxxabiv1::__cxa_throw( pCppExc, rtti, deleteException ); } -void fillUnoException( __cxa_exception * header, uno_Any * pUnoExc, uno_Mapping * pCpp2Uno ) +void fillUnoException( __cxxabiv1::__cxa_exception * header, uno_Any * pUnoExc, uno_Mapping * pCpp2Uno ) { if (! header) { diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx index 19399f35be0a..4112114b7566 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx @@ -59,53 +59,40 @@ extern "C" _LIBCPP_NORETURN void __cxa_throw( #else -namespace CPPU_CURRENT_NAMESPACE -{ - -// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h - -struct __cxa_exception -{ - ::std::type_info *exceptionType; - void (*exceptionDestructor)(void *); - - ::std::unexpected_handler unexpectedHandler; - ::std::terminate_handler terminateHandler; - - __cxa_exception *nextException; - +#if !HAVE_CXXABI_H_CXA_EH_GLOBALS +// <https://mentorembedded.github.io/cxx-abi/abi-eh.html>: +namespace __cxxabiv1 { +struct __cxa_exception { + std::type_info * exceptionType; + void (* exceptionDestructor)(void *); + std::unexpected_handler unexpectedHandler; + std::terminate_handler terminateHandler; + __cxa_exception * nextException; int handlerCount; - int handlerSwitchValue; - const unsigned char *actionRecord; - const unsigned char *languageSpecificData; - void *catchTemp; - void *adjustedPtr; - + char const * actionRecord; + char const * languageSpecificData; + void * catchTemp; + void * adjustedPtr; _Unwind_Exception unwindHeader; }; +} +#endif -struct __cxa_eh_globals -{ - __cxa_exception *caughtExceptions; +#if !HAVE_CXXABI_H_CXA_EH_GLOBALS +// <https://mentorembedded.github.io/cxx-abi/abi-eh.html>: +namespace __cxxabiv1 { +struct __cxa_eh_globals { + __cxa_exception * caughtExceptions; unsigned int uncaughtExceptions; }; - } - -// __cxa_get_globals is exported from libstdc++ since GCC 3.4.0 (CXXABI_1.3), -// but it is only declared in cxxabi.h (in namespace __cxxabiv1) since -// GCC 4.7.0. It returns a pointer to a struct __cxa_eh_globals, but that -// struct is only incompletely declared even in the GCC 4.7.0 cxxabi.h. -// Therefore, provide a declaration here for old GCC (libstdc++, really) version -// that returns a void pointer, and in the code calling it always cast to the -// above fake definition of CPPU_CURRENT_NAMESPACE::__cxa_eh_globals (which -// hopefully keeps matching the real definition in libstdc++); similarly for -// __cxa_allocate_exception and __cxa_throw, though they do not have the -// additional problem of an incompletely declared return type: +#endif #if !HAVE_CXXABI_H_CXA_GET_GLOBALS -namespace __cxxabiv1 { extern "C" void * __cxa_get_globals() throw(); } +namespace __cxxabiv1 { +extern "C" __cxa_eh_globals * __cxa_get_globals() throw(); +} #endif #if !HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION @@ -133,11 +120,7 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); void fillUnoException( -#ifdef _LIBCPP_VERSION __cxxabiv1::__cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno ); -#else - __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno ); -#endif } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx index a4686916ca1e..1f85882d2db2 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx @@ -294,17 +294,9 @@ static void cpp_call( catch (...) { // fill uno exception -#ifdef _LIBCPP_VERSION CPPU_CURRENT_NAMESPACE::fillUnoException( - reinterpret_cast< __cxxabiv1::__cxa_eh_globals * >( - __cxxabiv1::__cxa_get_globals())->caughtExceptions, + __cxxabiv1::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno()); -#else - fillUnoException( - reinterpret_cast< CPPU_CURRENT_NAMESPACE::__cxa_eh_globals * >( - __cxxabiv1::__cxa_get_globals())->caughtExceptions, - *ppUnoExc, pThis->getBridge()->getCpp2Uno()); -#endif // temporary params for ( ; nTempIndices--; ) diff --git a/config_host/config_cxxabi.h.in b/config_host/config_cxxabi.h.in index e3bb801d0469..09bf8ab6bc18 100644 --- a/config_host/config_cxxabi.h.in +++ b/config_host/config_cxxabi.h.in @@ -11,6 +11,8 @@ #define CONFIG_CXXABI_H #define HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION 0 +#define HAVE_CXXABI_H_CXA_EH_GLOBALS 0 +#define HAVE_CXXABI_H_CXA_EXCEPTION 0 #define HAVE_CXXABI_H_CXA_GET_GLOBALS 0 #define HAVE_CXXABI_H_CXA_THROW 0 diff --git a/configure.ac b/configure.ac index 1043c9fd60ac..658f2c8f1060 100644 --- a/configure.ac +++ b/configure.ac @@ -6052,6 +6052,30 @@ if test "$GCC" = "yes"; then ], [AC_MSG_RESULT([no])]) AC_LANG_POP([C++]) + AC_MSG_CHECKING([whether $CXX defines __cxa_eh_globals in cxxabi.h]) + AC_LANG_PUSH([C++]) + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include <cstddef> + #include <cxxabi.h> + std::size_t f() { return sizeof(__cxxabiv1::__cxa_eh_globals); } + ])], [ + AC_DEFINE([HAVE_CXXABI_H_CXA_EH_GLOBALS],[1]) + AC_MSG_RESULT([yes]) + ], [AC_MSG_RESULT([no])]) + AC_LANG_POP([C++]) + + AC_MSG_CHECKING([whether $CXX defines __cxa_exceptions in cxxabi.h]) + AC_LANG_PUSH([C++]) + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include <cstddef> + #include <cxxabi.h> + std::size_t f() { return sizeof(__cxxabiv1::__cxa_exceptions); } + ])], [ + AC_DEFINE([HAVE_CXXABI_H_CXA_EXCEPTIONS],[1]) + AC_MSG_RESULT([yes]) + ], [AC_MSG_RESULT([no])]) + AC_LANG_POP([C++]) + AC_MSG_CHECKING([whether $CXX declares __cxa_get_globals in cxxabi.h]) AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ |