From 10511acd0839635ce6595d9e5b8aa9136b6bde38 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 13 Nov 2012 15:32:30 +0000 Subject: Revert "sb140: #i117295# use rtl::Static" This reverts commit d3794d2d8ab2ee3f8118d61538bb753335b37f23. Conflicts: bridges/source/cpp_uno/cc50_solaris_intel/except.cxx bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx bridges/source/cpp_uno/gcc3_ios_arm/except.cxx bridges/source/cpp_uno/gcc3_linux_arm/except.cxx bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx --- .../source/cpp_uno/cc50_solaris_intel/except.cxx | 22 ++++++++++--- .../source/cpp_uno/cc50_solaris_sparc/except.cxx | 22 ++++++++++--- bridges/source/cpp_uno/gcc3_aix_powerpc/except.cxx | 19 ++++++++--- bridges/source/cpp_uno/gcc3_ios_arm/except.cxx | 21 +++++++++--- bridges/source/cpp_uno/gcc3_linux_alpha/except.cxx | 20 +++++++++--- bridges/source/cpp_uno/gcc3_linux_arm/except.cxx | 38 ++++++++++++++-------- bridges/source/cpp_uno/gcc3_linux_hppa/except.cxx | 20 +++++++++--- bridges/source/cpp_uno/gcc3_linux_ia64/except.cxx | 20 +++++++++--- bridges/source/cpp_uno/gcc3_linux_intel/except.cxx | 20 +++++++++--- bridges/source/cpp_uno/gcc3_linux_m68k/except.cxx | 20 +++++++++--- bridges/source/cpp_uno/gcc3_linux_mips/except.cxx | 20 +++++++++--- .../source/cpp_uno/gcc3_linux_powerpc/except.cxx | 20 +++++++++--- .../source/cpp_uno/gcc3_linux_powerpc64/except.cxx | 20 +++++++++--- bridges/source/cpp_uno/gcc3_linux_s390/except.cxx | 20 +++++++++--- bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx | 20 +++++++++--- bridges/source/cpp_uno/gcc3_linux_sparc/except.cxx | 20 +++++++++--- .../source/cpp_uno/gcc3_linux_x86-64/except.cxx | 14 +++++--- .../source/cpp_uno/gcc3_macosx_intel/except.cxx | 20 +++++++++--- .../source/cpp_uno/gcc3_macosx_powerpc/except.cxx | 20 +++++++++--- .../source/cpp_uno/gcc3_solaris_intel/except.cxx | 20 +++++++++--- .../source/cpp_uno/gcc3_solaris_sparc/except.cxx | 20 +++++++++--- bridges/source/cpp_uno/mingw_intel/except.cxx | 20 +++++++++--- bridges/source/cpp_uno/msvc_win32_intel/except.cxx | 18 ++++++++-- .../source/cpp_uno/msvc_win32_x86-64/except.cxx | 19 ++++++++--- 24 files changed, 388 insertions(+), 105 deletions(-) (limited to 'bridges/source') diff --git a/bridges/source/cpp_uno/cc50_solaris_intel/except.cxx b/bridges/source/cpp_uno/cc50_solaris_intel/except.cxx index ab029733cf54..90254ed49ce9 100644 --- a/bridges/source/cpp_uno/cc50_solaris_intel/except.cxx +++ b/bridges/source/cpp_uno/cc50_solaris_intel/except.cxx @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -308,8 +307,6 @@ void* RTTIHolder::generateRTTI( typelib_CompoundTypeDescription * pCompTypeDescr return pRTTI; } -struct RTTISingleton: public rtl::Static< RTTIHolder, RTTISingleton > {}; - //__________________________________________________________________________________________________ static void deleteException( @@ -342,7 +339,24 @@ void cc50_solaris_intel_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cp // will be released by deleteException typelib_typedescriptionreference_getDescription( &pTypeDescr, pUnoExc->pType ); - void * pRTTI = RTTISingleton::get().generateRTTI( (typelib_CompoundTypeDescription *)pTypeDescr ); + void* pRTTI; + { + static ::osl::Mutex aMutex; + ::osl::Guard< ::osl::Mutex > guard( aMutex ); + + static RTTIHolder * s_pRTTI = 0; + if (! s_pRTTI) + { +#ifdef LEAK_STATIC_DATA + s_pRTTI = new RTTIHolder(); +#else + static RTTIHolder s_aRTTI; + s_pRTTI = &s_aRTTI; +#endif + } + + pRTTI = s_pRTTI->generateRTTI( (typelib_CompoundTypeDescription *)pTypeDescr ); + } // a must be OSL_ENSURE( sizeof(sal_Int32) == sizeof(void *), "### pointer size differs from sal_Int32!" ); diff --git a/bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx b/bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx index 75b23c61073d..df832f89085e 100644 --- a/bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx +++ b/bridges/source/cpp_uno/cc50_solaris_sparc/except.cxx @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -314,8 +313,6 @@ void* RTTIHolder::generateRTTI( typelib_CompoundTypeDescription * pCompTypeDescr return pRTTI; } -struct RTTISingleton: public rtl::Static< RTTIHolder, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( @@ -349,7 +346,24 @@ void cc50_solaris_sparc_raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cp // will be released by deleteException typelib_typedescriptionreference_getDescription( &pTypeDescr, pUnoExc->pType ); - void * pRTTI = RTTISingleton::get().generateRTTI( (typelib_CompoundTypeDescription *)pTypeDescr ); + void* pRTTI; + { + static ::osl::Mutex aMutex; + ::osl::Guard< ::osl::Mutex > guard( aMutex ); + + static RTTIHolder * s_pRTTI = 0; + if (! s_pRTTI) + { +#ifdef LEAK_STATIC_DATA + s_pRTTI = new RTTIHolder(); +#else + static RTTIHolder s_aRTTI; + s_pRTTI = &s_aRTTI; +#endif + } + + pRTTI = s_pRTTI->generateRTTI( (typelib_CompoundTypeDescription *)pTypeDescr ); + } // a must be OSL_ENSURE( sizeof(sal_Int32) == sizeof(void *), "### pointer size differs from sal_Int32!" ); diff --git a/bridges/source/cpp_uno/gcc3_aix_powerpc/except.cxx b/bridges/source/cpp_uno/gcc3_aix_powerpc/except.cxx index fe0a556d9090..817267cfe50e 100644 --- a/bridges/source/cpp_uno/gcc3_aix_powerpc/except.cxx +++ b/bridges/source/cpp_uno/gcc3_aix_powerpc/except.cxx @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -204,8 +203,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -241,7 +238,21 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); // avoiding locked counts - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_ios_arm/except.cxx b/bridges/source/cpp_uno/gcc3_ios_arm/except.cxx index 6f78313429cd..3f551c90e928 100644 --- a/bridges/source/cpp_uno/gcc3_ios_arm/except.cxx +++ b/bridges/source/cpp_uno/gcc3_ios_arm/except.cxx @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -208,8 +207,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -256,7 +253,23 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_alpha/except.cxx b/bridges/source/cpp_uno/gcc3_linux_alpha/except.cxx index 09cdb4526d6c..7dc3ab50f625 100644 --- a/bridges/source/cpp_uno/gcc3_linux_alpha/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_alpha/except.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -205,8 +204,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -241,7 +238,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_arm/except.cxx b/bridges/source/cpp_uno/gcc3_linux_arm/except.cxx index 6773228402d6..f84ffdc7bdc6 100644 --- a/bridges/source/cpp_uno/gcc3_linux_arm/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_arm/except.cxx @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -230,8 +229,6 @@ namespace CPPU_CURRENT_NAMESPACE return rtti; } - struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //------------------------------------------------------------------ static void deleteException( void * pExc ) { @@ -276,19 +273,34 @@ namespace CPPU_CURRENT_NAMESPACE pCppExc = __cxa_allocate_exception( pTypeDescr->nSize ); ::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp ); - // destruct uno exception - ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); - TYPELIB_DANGER_RELEASE( pTypeDescr ); - OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); - if (! rtti) + // destruct uno exception + ::uno_any_destruct( pUnoExc, 0 ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) { - throw RuntimeException( - OUString( RTL_CONSTASCII_USTRINGPARAM("no rtti for type ") ) + - *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ), - Reference< XInterface >() ); +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif } } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); + if (! rtti) + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM("no rtti for type ") ) + + *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ), + Reference< XInterface >() ); + } + } __cxa_throw( pCppExc, rtti, deleteException ); } diff --git a/bridges/source/cpp_uno/gcc3_linux_hppa/except.cxx b/bridges/source/cpp_uno/gcc3_linux_hppa/except.cxx index b743471adb56..77a12507ede4 100644 --- a/bridges/source/cpp_uno/gcc3_linux_hppa/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_hppa/except.cxx @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -206,8 +205,6 @@ namespace CPPU_CURRENT_NAMESPACE return rtti; } - struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //------------------------------------------------------------------ static void deleteException( void * pExc ) { @@ -254,7 +251,22 @@ namespace CPPU_CURRENT_NAMESPACE // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_ia64/except.cxx b/bridges/source/cpp_uno/gcc3_linux_ia64/except.cxx index 73ea00a94404..7dc3ab50f625 100644 --- a/bridges/source/cpp_uno/gcc3_linux_ia64/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_ia64/except.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -205,8 +204,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -241,7 +238,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx b/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx index e7e6e943aaac..d354a9d4151a 100644 --- a/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_intel/except.cxx @@ -37,7 +37,6 @@ #define _GLIBCXX_CDTOR_CALLABI #endif -#include #include #include #include @@ -216,8 +215,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- extern "C" { static void _GLIBCXX_CDTOR_CALLABI deleteException( void * pExc ) @@ -266,7 +263,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_m68k/except.cxx b/bridges/source/cpp_uno/gcc3_linux_m68k/except.cxx index b743471adb56..77a12507ede4 100644 --- a/bridges/source/cpp_uno/gcc3_linux_m68k/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_m68k/except.cxx @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -206,8 +205,6 @@ namespace CPPU_CURRENT_NAMESPACE return rtti; } - struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //------------------------------------------------------------------ static void deleteException( void * pExc ) { @@ -254,7 +251,22 @@ namespace CPPU_CURRENT_NAMESPACE // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_mips/except.cxx b/bridges/source/cpp_uno/gcc3_linux_mips/except.cxx index c94d32d68fd5..d4d1c0ec7f3b 100644 --- a/bridges/source/cpp_uno/gcc3_linux_mips/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_mips/except.cxx @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -203,8 +202,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -251,7 +248,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc/except.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc/except.cxx index 73ea00a94404..7dc3ab50f625 100644 --- a/bridges/source/cpp_uno/gcc3_linux_powerpc/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_powerpc/except.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -205,8 +204,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -241,7 +238,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc64/except.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc64/except.cxx index 73ea00a94404..7dc3ab50f625 100644 --- a/bridges/source/cpp_uno/gcc3_linux_powerpc64/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_powerpc64/except.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -205,8 +204,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -241,7 +238,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_s390/except.cxx b/bridges/source/cpp_uno/gcc3_linux_s390/except.cxx index 73ea00a94404..7dc3ab50f625 100644 --- a/bridges/source/cpp_uno/gcc3_linux_s390/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_s390/except.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -205,8 +204,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -241,7 +238,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx b/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx index 09cdb4526d6c..7dc3ab50f625 100644 --- a/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -205,8 +204,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -241,7 +238,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_linux_sparc/except.cxx b/bridges/source/cpp_uno/gcc3_linux_sparc/except.cxx index d8fc0a427702..c1f5b5923aed 100644 --- a/bridges/source/cpp_uno/gcc3_linux_sparc/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_sparc/except.cxx @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -204,8 +203,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -252,7 +249,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) 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 648a09e1b6c0..3b003f0d758b 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx @@ -38,12 +38,12 @@ #include -#include -#include #include #include +#include #include #include +#include #include #include "com/sun/star/uno/RuntimeException.hpp" @@ -216,8 +216,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- extern "C" { static void _GLIBCXX_CDTOR_CALLABI deleteException( void * pExc ) @@ -235,6 +233,11 @@ static void _GLIBCXX_CDTOR_CALLABI deleteException( void * pExc ) } } +namespace +{ + struct theRTTI : public rtl::Static {}; +} + //================================================================================================== void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) { @@ -267,7 +270,8 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); // avoiding locked counts - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + static RTTI &rRTTI = theRTTI::get(); + rtti = rRTTI.getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_macosx_intel/except.cxx b/bridges/source/cpp_uno/gcc3_macosx_intel/except.cxx index d39b194578aa..7728d554fe84 100644 --- a/bridges/source/cpp_uno/gcc3_macosx_intel/except.cxx +++ b/bridges/source/cpp_uno/gcc3_macosx_intel/except.cxx @@ -36,7 +36,6 @@ #endif #include -#include #include #include #include @@ -272,8 +271,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -320,7 +317,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_macosx_powerpc/except.cxx b/bridges/source/cpp_uno/gcc3_macosx_powerpc/except.cxx index 19b2dc609bd1..df01722c831d 100644 --- a/bridges/source/cpp_uno/gcc3_macosx_powerpc/except.cxx +++ b/bridges/source/cpp_uno/gcc3_macosx_powerpc/except.cxx @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -204,8 +203,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -240,7 +237,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_solaris_intel/except.cxx b/bridges/source/cpp_uno/gcc3_solaris_intel/except.cxx index 7b8de07397a0..2148054e3522 100644 --- a/bridges/source/cpp_uno/gcc3_solaris_intel/except.cxx +++ b/bridges/source/cpp_uno/gcc3_solaris_intel/except.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -206,8 +205,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -254,7 +251,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/gcc3_solaris_sparc/except.cxx b/bridges/source/cpp_uno/gcc3_solaris_sparc/except.cxx index bcf23e26a7a8..4f84e6de24e3 100644 --- a/bridges/source/cpp_uno/gcc3_solaris_sparc/except.cxx +++ b/bridges/source/cpp_uno/gcc3_solaris_sparc/except.cxx @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -203,8 +202,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- static void deleteException( void * pExc ) { @@ -251,7 +248,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/mingw_intel/except.cxx b/bridges/source/cpp_uno/mingw_intel/except.cxx index 308ccb842e74..d347542006f8 100644 --- a/bridges/source/cpp_uno/mingw_intel/except.cxx +++ b/bridges/source/cpp_uno/mingw_intel/except.cxx @@ -37,7 +37,6 @@ #include -#include #include #include #include @@ -195,8 +194,6 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR return rtti; } -struct RTTISingleton: public rtl::Static< RTTI, RTTISingleton > {}; - //-------------------------------------------------------------------------------------------------- extern "C" { static void _GLIBCXX_CDTOR_CALLABI deleteException( void * pExc ) @@ -245,7 +242,22 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) // destruct uno exception ::uno_any_destruct( pUnoExc, 0 ); - rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); + // avoiding locked counts + static RTTI * s_rtti = 0; + if (! s_rtti) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_rtti) + { +#ifdef LEAK_STATIC_DATA + s_rtti = new RTTI(); +#else + static RTTI rtti_data; + s_rtti = &rtti_data; +#endif + } + } + rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); TYPELIB_DANGER_RELEASE( pTypeDescr ); OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); if (! rtti) diff --git a/bridges/source/cpp_uno/msvc_win32_intel/except.cxx b/bridges/source/cpp_uno/msvc_win32_intel/except.cxx index ed2e89bcacf2..94cbbff8ca50 100644 --- a/bridges/source/cpp_uno/msvc_win32_intel/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_intel/except.cxx @@ -36,7 +36,6 @@ #include #include "rtl/alloc.h" -#include #include "rtl/strbuf.hxx" #include "rtl/ustrbuf.hxx" @@ -184,7 +183,6 @@ RTTInfos::~RTTInfos() throw () } } -struct RTTISingleton: public rtl::Static< RTTInfos, RTTISingleton > {}; //################################################################################################## //#### Exception raising ########################################################################### @@ -455,7 +453,21 @@ void * ExceptionInfos::getRaiseInfo( typelib_TypeDescription * pTypeDescr ) thro //################################################################################################## type_info * msci_getRTTI( OUString const & rUNOname ) { - return RTTISingleton::get().getRTTI( rUNOname ); + static RTTInfos * s_pRTTIs = 0; + if (! s_pRTTIs) + { + MutexGuard aGuard( Mutex::getGlobalMutex() ); + if (! s_pRTTIs) + { +#ifdef LEAK_STATIC_DATA + s_pRTTIs = new RTTInfos(); +#else + static RTTInfos s_aRTTIs; + s_pRTTIs = &s_aRTTIs; +#endif + } + } + return s_pRTTIs->getRTTI( rUNOname ); } //################################################################################################## diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx index e7ce54915fd0..3289b1d6c080 100644 --- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx @@ -252,7 +252,6 @@ void #include #include "rtl/alloc.h" -#include #include "rtl/strbuf.hxx" #include "rtl/ustrbuf.hxx" @@ -659,12 +658,24 @@ RaiseInfo * ExceptionInfos::getRaiseInfo( typelib_TypeDescription * pTD ) throw return pRaiseInfo; } -struct RTTISingleton: public rtl::Static< RTTInfos, RTTISingleton > {}; - type_info * mscx_getRTTI( OUString const & rUNOname ) { - return RTTISingleton::get().getRTTI( rUNOname ); + static RTTInfos * s_pRTTIs = 0; + if (! s_pRTTIs) + { + MutexGuard aGuard( Mutex::getGlobalMutex() ); + if (! s_pRTTIs) + { +#ifdef LEAK_STATIC_DATA + s_pRTTIs = new RTTInfos(); +#else + static RTTInfos s_aRTTIs; + s_pRTTIs = &s_aRTTIs; +#endif + } + } + return s_pRTTIs->getRTTI( rUNOname ); } void mscx_raiseException( -- cgit