From f5792667cafef77cc4c142f4261f8b64280bc0fe Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 19 Jul 2016 15:12:55 +0100 Subject: hack for now Change-Id: I62673e60ac8785c74fc4f97ad76bcb02c7e28941 --- bridges/source/cpp_uno/gcc3_linux_intel/share.hxx | 19 ++- .../source/cpp_uno/gcc3_linux_x86-64/except.cxx | 4 +- bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx | 172 +++++++++------------ .../source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx | 10 +- bridges/source/cpp_uno/msvc_win32_intel/except.cxx | 1 - 5 files changed, 99 insertions(+), 107 deletions(-) (limited to 'bridges/source') diff --git a/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx b/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx index f97e81e419eb..512ae6db2c03 100644 --- a/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx +++ b/bridges/source/cpp_uno/gcc3_linux_intel/share.hxx @@ -27,9 +27,8 @@ #ifndef _GLIBCXX_CDTOR_CALLABI // new in GCC 4.7 cxxabi.h #define _GLIBCXX_CDTOR_CALLABI #endif -#include -#include "config_cxxabi.h" +#include "config_gcc.h" #include #include "uno/mapping.h" @@ -38,7 +37,15 @@ namespace CPPU_CURRENT_NAMESPACE void dummy_can_throw_anything( char const * ); -// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h +// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h + +struct _Unwind_Exception +{ + unsigned exception_class __attribute__((__mode__(__DI__))); + void * exception_cleanup; + unsigned private_1 __attribute__((__mode__(__word__))); + unsigned private_2 __attribute__((__mode__(__word__))); +} __attribute__((__aligned__)); struct __cxa_exception { @@ -80,17 +87,17 @@ struct __cxa_eh_globals // __cxa_allocate_exception and __cxa_throw, though they do not have the // additional problem of an incompletely declared return type: -#if !HAVE_CXXABI_H_CXA_GET_GLOBALS +#if !HAVE_GCC_CXXABI_H_CXA_GET_GLOBALS namespace __cxxabiv1 { extern "C" void * __cxa_get_globals() throw(); } #endif -#if !HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION +#if !HAVE_GCC_CXXABI_H_CXA_ALLOCATE_EXCEPTION namespace __cxxabiv1 { extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) throw(); } #endif -#if !HAVE_CXXABI_H_CXA_THROW +#if !HAVE_GCC_CXXABI_H_CXA_THROW namespace __cxxabiv1 { extern "C" void __cxa_throw( void * thrown_exception, void * tinfo, void (* dest)(void *)) 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 04d13e80c748..5efd7cb752e8 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 ) { - __cxxabiv1::__cxa_exception const * header = (static_cast<__cxxabiv1::__cxa_exception const *>(pExc) - 1); + __cxa_exception const * header = (static_cast<__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( __cxxabiv1::__cxa_exception * header, uno_Any * pUnoExc, uno_Mapping * pCpp2Uno ) +void fillUnoException( __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 bac7ef6fec15..96ddfc0be0b3 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx @@ -27,129 +27,101 @@ #ifndef _GLIBCXX_CDTOR_CALLABI // new in GCC 4.7 cxxabi.h #define _GLIBCXX_CDTOR_CALLABI #endif -#include -#include "config_cxxabi.h" +#include "config_gcc.h" #include "uno/any2.h" #include "uno/mapping.h" -#if !HAVE_CXXABI_H_CLASS_TYPE_INFO -// , -// libstdc++-v3/libsupc++/cxxabi.h: -namespace __cxxabiv1 { -class __class_type_info: public std::type_info { -public: - explicit __class_type_info(char const * n): type_info(n) {} - ~__class_type_info() override; -}; -} -#endif +#ifdef _LIBCPP_VERSION -#if !HAVE_CXXABI_H_SI_CLASS_TYPE_INFO -// , -// libstdc++-v3/libsupc++/cxxabi.h: -namespace __cxxabiv1 { -class __si_class_type_info: public __class_type_info { -public: - __class_type_info const * __base_type; - explicit __si_class_type_info( - char const * n, __class_type_info const *base): - __class_type_info(n), __base_type(base) {} - ~__si_class_type_info() override; -}; -} -#endif - -#if !HAVE_CXXABI_H_BASE_CLASS_TYPE_INFO -// , -// libstdc++-v3/libsupc++/cxxabi.h: -namespace __cxxabiv1 { -struct __base_class_type_info { - __class_type_info const * __base_type; -#if defined _GLIBCXX_LLP64 - long long __offset_flags; -#else - long __offset_flags; -#endif - enum __offset_flags_masks { - __virtual_mask = 0x1, - __public_mask = 0x2, - __offset_shift = 8 +namespace __cxxabiv1 +{ + struct __class_type_info : public std::type_info + { + explicit __class_type_info( const char *__n ) : type_info( __n ) { } + virtual ~__class_type_info(); }; -}; -} -#endif -#if !HAVE_CXXABI_H_VMI_CLASS_TYPE_INFO -// , -// libstdc++-v3/libsupc++/cxxabi.h: -namespace __cxxabiv1 { -class __vmi_class_type_info: public __class_type_info { -public: - unsigned int __flags; - unsigned int __base_count; - __base_class_type_info __base_info[1]; - enum __flags_masks { - __non_diamond_repeat_mask = 0x1, - __diamond_shaped_mask = 0x2, - __flags_unknown_mask = 0x10 + struct __si_class_type_info : public __class_type_info + { + explicit __si_class_type_info( const char *__n, const __class_type_info *__b ) : + __class_type_info( __n ), __base_type( __b ) { } + virtual ~__si_class_type_info(); + const __class_type_info *__base_type; }; - explicit __vmi_class_type_info(char const * n, int flags): - __class_type_info(n), __flags(flags), __base_count(0) {} - ~__vmi_class_type_info() override; -}; + +extern "C" void *__cxa_allocate_exception( std::size_t thrown_size ) _NOEXCEPT; + +extern "C" _LIBCPP_NORETURN void __cxa_throw( + void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ); } -#endif -#if !HAVE_CXXABI_H_CXA_EH_GLOBALS -// , -// libcxxabi/src/cxa_exception.hpp: -namespace __cxxabiv1 { -struct __cxa_exception { -#if defined _LIBCPPABI_VERSION // detect libc++abi -#if defined __LP64__ || LIBCXXABI_ARM_EHABI - std::size_t referenceCount; -#endif -#endif - std::type_info * exceptionType; - void (* exceptionDestructor)(void *); - std::unexpected_handler unexpectedHandler; - std::terminate_handler terminateHandler; - __cxa_exception * nextException; +#else + +namespace CPPU_CURRENT_NAMESPACE +{ + +// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h + +struct _Unwind_Exception +{ + unsigned exception_class __attribute__((__mode__(__DI__))); + void * exception_cleanup; + unsigned private_1 __attribute__((__mode__(__word__))); + unsigned private_2 __attribute__((__mode__(__word__))); +} __attribute__((__aligned__)); + +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; - char const * actionRecord; - char const * languageSpecificData; - void * catchTemp; - void * adjustedPtr; + const unsigned char *actionRecord; + const unsigned char *languageSpecificData; + void *catchTemp; + void *adjustedPtr; + _Unwind_Exception unwindHeader; }; -} -#endif -#if !HAVE_CXXABI_H_CXA_EH_GLOBALS -// : -namespace __cxxabiv1 { -struct __cxa_eh_globals { - __cxa_exception * caughtExceptions; +struct __cxa_eh_globals +{ + __cxa_exception *caughtExceptions; unsigned int uncaughtExceptions; }; -} -#endif -#if !HAVE_CXXABI_H_CXA_GET_GLOBALS -namespace __cxxabiv1 { -extern "C" __cxa_eh_globals * __cxa_get_globals() throw(); } + +// __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: + +#if !HAVE_GCC_CXXABI_H_CXA_GET_GLOBALS +namespace __cxxabiv1 { extern "C" void * __cxa_get_globals() throw(); } #endif -#if !HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION +#if !HAVE_GCC_CXXABI_H_CXA_ALLOCATE_EXCEPTION namespace __cxxabiv1 { extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) throw(); } #endif -#if !HAVE_CXXABI_H_CXA_THROW +#if !HAVE_GCC_CXXABI_H_CXA_THROW namespace __cxxabiv1 { extern "C" void __cxa_throw( void * thrown_exception, void * tinfo, void (* dest)(void *)) @@ -157,6 +129,8 @@ extern "C" void __cxa_throw( } #endif +#endif + extern "C" void privateSnippetExecutor( ... ); namespace CPPU_CURRENT_NAMESPACE @@ -166,7 +140,11 @@ 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 71e76a9f3b09..f65ac57f0002 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx @@ -294,9 +294,17 @@ static void cpp_call( catch (...) { // fill uno exception +#ifdef _LIBCPP_VERSION CPPU_CURRENT_NAMESPACE::fillUnoException( - __cxxabiv1::__cxa_get_globals()->caughtExceptions, + reinterpret_cast< __cxxabiv1::__cxa_eh_globals * >( + __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/bridges/source/cpp_uno/msvc_win32_intel/except.cxx b/bridges/source/cpp_uno/msvc_win32_intel/except.cxx index d6c6271802c7..8dd8810a5f11 100644 --- a/bridges/source/cpp_uno/msvc_win32_intel/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_intel/except.cxx @@ -28,7 +28,6 @@ #include "rtl/strbuf.hxx" #include "rtl/ustrbuf.hxx" #include -#include #include "com/sun/star/uno/Any.hxx" #include -- cgit