diff options
-rw-r--r-- | cppu/source/uno/lbenv.cxx | 17 | ||||
-rw-r--r-- | cppu/source/uno/lbmap.cxx | 65 | ||||
-rw-r--r-- | cppuhelper/source/shlib.cxx | 36 | ||||
-rw-r--r-- | sal/Library_sal.mk | 1 | ||||
-rw-r--r-- | sal/cppunittester/cppunittester.cxx | 4 | ||||
-rw-r--r-- | sal/inc/cppunittester/protectorfactory.hxx | 2 | ||||
-rw-r--r-- | sal/osl/unx/module.cxx | 22 | ||||
-rw-r--r-- | sal/osl/unx/process_impl.cxx | 14 | ||||
-rw-r--r-- | sal/rtl/source/unload.cxx | 50 | ||||
-rw-r--r-- | sal/textenc/textenc.cxx | 2 | ||||
-rw-r--r-- | stoc/source/bootstrap/services.cxx | 4 | ||||
-rw-r--r-- | stoc/source/loader/dllcomponentloader.cxx | 7 |
12 files changed, 184 insertions, 40 deletions
diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx index baced8b1d3dd..0fc5239fddb9 100644 --- a/cppu/source/uno/lbenv.cxx +++ b/cppu/source/uno/lbenv.cxx @@ -1061,13 +1061,22 @@ inline void EnvironmentsData::getRegisteredEnvironments( static bool loadEnv(OUString const & cLibStem, uno_Environment * pEnv) { -#ifdef IOS +#ifdef DISABLE_DYNLOADING oslModule hMod; uno_initEnvironmentFunc fpInit = NULL; - if (cLibStem.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("gcc3_uno")) ) - fpInit = gcc3_uno_initEnvironment; - osl_getModuleHandle( NULL, &hMod ); + if (cLibStem.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME "_uno")) ) + fpInit = CPPU_ENV_uno_initEnvironment; + else + { +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE( "%s: Unhandled env: %s", __PRETTY_FUNCTION__, OUStringToOString( cLibStem, RTL_TEXTENCODING_ASCII_US).getStr() ); +#endif + return false; + } + // In the DISABLE_DYNLOADING case the functions that hMod is + // passed to below don't do anything with it anyway. + hMod = 0; #else // late init with some code from matching uno language binding // will be unloaded by environment diff --git a/cppu/source/uno/lbmap.cxx b/cppu/source/uno/lbmap.cxx index 070e2dde8367..219a4bfb358b 100644 --- a/cppu/source/uno/lbmap.cxx +++ b/cppu/source/uno/lbmap.cxx @@ -330,7 +330,29 @@ static inline void setNegativeBridge( const OUString & rBridgeName ) MutexGuard aGuard( rData.aNegativeLibsMutex ); rData.aNegativeLibs.insert( rBridgeName ); } -//================================================================================================== + +#ifdef DISABLE_DYNLOADING + +static uno_ext_getMappingFunc selectMapFunc( const OUString & rBridgeName ) + SAL_THROW(()) +{ + if (rBridgeName.equalsAscii( CPPU_CURRENT_LANGUAGE_BINDING_NAME "_uno" )) + return CPPU_ENV_uno_ext_getMapping; +#ifndef IOS + // I don't think the affine or log bridges will be needed on iOS, + // and DISABLE_DYNLOADING will hardly be used elsewhere, but if + // somebody wants to experiment, need to find out then whether + // these are needed. + if (rBridgeName.equalsAscii( "affine_uno_uno" )) + return affine_uno_uno_ext_getMapping; + if (rBridgeName.equalsAscii( "log_uno_uno" )) + return log_uno_uno_ext_getMapping; +#endif + return 0; +} + +#else + static inline oslModule loadModule( const OUString & rBridgeName ) SAL_THROW(()) { @@ -353,6 +375,9 @@ static inline oslModule loadModule( const OUString & rBridgeName ) } return 0; } + +#endif + //================================================================================================== static Mapping loadExternalMapping( const Environment & rFrom, const Environment & rTo, const OUString & rAddPurpose ) @@ -361,6 +386,43 @@ static Mapping loadExternalMapping( OSL_ASSERT( rFrom.is() && rTo.is() ); if (rFrom.is() && rTo.is()) { +#ifdef DISABLE_DYNLOADING + OUString aName; + uno_ext_getMappingFunc fpGetMapFunc = 0; + + if (EnvDcp::getTypeName(rFrom.getTypeName()).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_UNO) )) + { + aName = getBridgeName( rTo, rFrom, rAddPurpose ); + fpGetMapFunc = selectMapFunc( aName ); + } + if (! fpGetMapFunc) + { + aName = getBridgeName( rFrom, rTo, rAddPurpose ); + fpGetMapFunc = selectMapFunc( aName ); + } + if (! fpGetMapFunc) + { + aName = getBridgeName( rTo, rFrom, rAddPurpose ); + fpGetMapFunc = selectMapFunc( aName ); + } + + if (! fpGetMapFunc) + { +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE( "Could not find mapfunc for %s", OUStringToOString( aName, RTL_TEXTENCODING_ASCII_US ).getStr()); +#endif + return Mapping(); + } + + if (fpGetMapFunc) + { + Mapping aExt; + (*fpGetMapFunc)( (uno_Mapping **)&aExt, rFrom.get(), rTo.get() ); + OSL_ASSERT( aExt.is() ); + if (aExt.is()) + return aExt; + } +#else // find proper lib oslModule hModule = 0; OUString aName; @@ -393,6 +455,7 @@ static Mapping loadExternalMapping( ::osl_unloadModule( hModule ); setNegativeBridge( aName ); } +#endif } return Mapping(); } diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx index 068a50a27247..3c1445e02b10 100644 --- a/cppuhelper/source/shlib.cxx +++ b/cppuhelper/source/shlib.cxx @@ -127,7 +127,8 @@ namespace class theAccessDPath : public rtl::Static<buildAccessDPath, theAccessDPath> {}; } -//------------------------------------------------------------------------------ +#ifndef DISABLE_DYNLOADING + static const ::std::vector< OUString > * getAccessDPath() SAL_THROW(()) { return theAccessDPath::get().getAccessDPath(); @@ -321,6 +322,8 @@ static void getLibEnv(oslModule lib, } } +#endif + extern "C" {static void s_getFactory(va_list * pParam) { component_getFactoryFunc pSym = va_arg(*pParam, component_getFactoryFunc); @@ -361,7 +364,21 @@ Reference< XInterface > invokeComponentFactory( uno::Environment env; OUString aEnvTypeName; +#ifdef DISABLE_DYNLOADING + (void) lib; + (void) rPrefix; + // It seems that the only UNO components that have + // component_getImplementationEnvironment functions are the JDBC + // and ADO (whatever that is) database connectivity thingies + // neither of which make sense on iOS (which is the only platform + // for which DISABLE_DYNLOADING is intended, really). So we can + // simoly bypass the getLibEnv() stuff and don't need to wonder + // how to find out what function to call at this point if + // statically linked. + aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +#else getLibEnv(lib, &env, &aEnvTypeName, currentEnv, rImplName, rPrefix); +#endif OString aImplName( OUStringToOString( rImplName, RTL_TEXTENCODING_ASCII_US ) ); @@ -439,7 +456,7 @@ Reference< XInterface > invokeComponentFactory( } // namespace -#ifdef IOS +#ifdef DISABLE_DYNLOADING extern "C" { // In stoc/source/bootstrap/services.cxx. @@ -461,7 +478,7 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( OUString const & rPrefix ) SAL_THROW( (loader::CannotActivateFactoryException) ) { -#ifndef IOS +#ifndef DISABLE_DYNLOADING OUString sLibName(rLibName); #ifdef ANDROID @@ -506,13 +523,20 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( oslGenericFunction pSym = NULL; -#ifdef IOS +#ifdef DISABLE_DYNLOADING if ( rLibName.equals( OUSTR("bootstrap.uno" SAL_DLLEXTENSION)) ) pSym = (oslGenericFunction) bootstrap_component_getFactory; + else + { +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE( "%s: attempting to load unknown library %s", __PRETTY_FUNCTION__, OUStringToOString( rLibName, RTL_TEXTENCODING_ASCII_US ).getStr() ); #endif + } +#else if ( pSym == NULL ) pSym = osl_getFunctionSymbol( lib, aGetFactoryName.pData ); +#endif if (pSym != 0) { @@ -573,6 +597,8 @@ Reference< XInterface > SAL_CALL invokeStaticComponentFactory( return xRet; } +#ifndef DISABLE_DYNLOADING + //============================================================================== extern "C" { static void s_writeInfo(va_list * pParam) { @@ -697,6 +723,8 @@ void SAL_CALL writeSharedLibComponentInfo( } } +#endif // DISABLE_DYNLOADING + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk index 79d64a5249e1..f54123b7b0bb 100644 --- a/sal/Library_sal.mk +++ b/sal/Library_sal.mk @@ -46,7 +46,6 @@ $(eval $(call gb_Library_add_defs,sal,\ -DFORCE_SYSALLOC \ ) \ $(if $(filter $(OS),IOS), \ - -DNO_DL_FUNCTIONS \ -DNO_CHILD_PROCESSES \ ) \ $(LFS_CFLAGS) \ diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx index a34ea6142a79..40ad28cdea85 100644 --- a/sal/cppunittester/cppunittester.cxx +++ b/sal/cppunittester/cppunittester.cxx @@ -128,7 +128,7 @@ public: } bool run() const { -#ifdef IOS +#ifdef DISABLE_DYNLOADING // For iOS cppunit plugins aren't really "plugins" (shared // libraries), but just static archives. In the real main // program of a cppunit app, which calls the lo_main() that @@ -206,7 +206,7 @@ SAL_IMPLEMENT_MAIN() { if (rtl_getAppCommandArgCount() - index < 3) { usageFailure(); } -#ifndef IOS +#ifndef DISABLE_DYNLOADING rtl::OUString lib(getArgument(index + 1)); rtl::OUString sym(getArgument(index + 2)); modules.push_back(new osl::Module(lib, SAL_LOADMODULE_GLOBAL)); diff --git a/sal/inc/cppunittester/protectorfactory.hxx b/sal/inc/cppunittester/protectorfactory.hxx index a6e1d2eec8a8..093eb5f5d588 100644 --- a/sal/inc/cppunittester/protectorfactory.hxx +++ b/sal/inc/cppunittester/protectorfactory.hxx @@ -50,7 +50,7 @@ namespace cppunittester extern "C" typedef LibreOfficeProtector * SAL_CALL ProtectorFactory(); } -#ifdef IOS +#ifdef DISABLE_DYNLOADING extern "C" CppUnit::Protector *unoexceptionprotector(); #endif diff --git a/sal/osl/unx/module.cxx b/sal/osl/unx/module.cxx index 419bfc570aa4..e430cd39e351 100644 --- a/sal/osl/unx/module.cxx +++ b/sal/osl/unx/module.cxx @@ -50,8 +50,8 @@ extern "C" int UnicodeToText(char *, size_t, const sal_Unicode *, sal_Int32); static sal_Bool getModulePathFromAddress(void * address, rtl_String ** path) { sal_Bool result = sal_False; -/* Bah, we do want to use dladdr here also on iOS, I think? */ -#if !defined(NO_DL_FUNCTIONS) || defined(IOS) + // We do want to have this functionality also in the + // DISABLE_DYNLOADING case, I think? #if defined(AIX) int size = 4 * 1024; char *buf, *filename=NULL; @@ -115,7 +115,6 @@ static sal_Bool getModulePathFromAddress(void * address, rtl_String ** path) { result = sal_False; } #endif -#endif return result; } @@ -158,7 +157,7 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR "sal.osl", "only either LAZY or NOW"); if (pModuleName) { -#ifndef NO_DL_FUNCTIONS +#ifndef DISABLE_DYNLOADING #ifdef ANDROID (void) nRtldMode; void *pLib = lo_dlopen(pModuleName); @@ -175,10 +174,10 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR #endif return ((oslModule)(pLib)); -#else /* NO_DL_FUNCTIONS */ +#else /* DISABLE_DYNLOADING */ (void) nRtldMode; printf("No DL Functions\n"); -#endif /* NO_DL_FUNCTIONS */ +#endif /* DISABLE_DYNLOADING */ } return NULL; } @@ -220,7 +219,7 @@ oslModule osl_loadModuleRelativeAscii( sal_Bool SAL_CALL osl_getModuleHandle(rtl_uString *, oslModule *pResult) { -#if !defined(NO_DL_FUNCTIONS) || defined(IOS) +#if !defined(DISABLE_DYNLOADING) || defined(IOS) *pResult = (oslModule) RTLD_DEFAULT; #else *pResult = NULL; @@ -235,7 +234,7 @@ void SAL_CALL osl_unloadModule(oslModule hModule) { if (hModule) { -#ifndef NO_DL_FUNCTIONS +#ifndef DISABLE_DYNLOADING #ifdef ANDROID int nRet = lo_dlclose(hModule); #else @@ -243,7 +242,7 @@ void SAL_CALL osl_unloadModule(oslModule hModule) #endif SAL_INFO_IF( nRet != 0, "sal.osl", "dlclose(" << hModule << "): " << dlerror()); -#endif /* ifndef NO_DL_FUNCTIONS */ +#endif /* ifndef DISABLE_DYNLOADING */ } } @@ -265,8 +264,8 @@ osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol) { void *fcnAddr = NULL; -/* We do want to use dlsym on iOS */ -#if !defined(NO_DL_FUNCTIONS) || defined(IOS) + // We do want to use dlsym() also in the DISABLE_DYNLOADING case + // just to look up symbols in the static executable, I think. if (pSymbol) { fcnAddr = dlsym(Module, pSymbol); @@ -274,7 +273,6 @@ osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol) fcnAddr == 0, "sal.osl", "dlsym(" << Module << ", " << pSymbol << "): " << dlerror()); } -#endif return (oslGenericFunction) fcnAddr; } diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index 94128a2d29f2..3c1831d1b598 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -119,7 +119,7 @@ oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( return (result); } -#elif !defined(NO_DL_FUNCTIONS) +#else #include <dlfcn.h> oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( @@ -169,17 +169,7 @@ oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( return (result); } -#else /* NO_DL_FUNCTIONS */ - -oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl ( - rtl_uString ** ppFileURL -) SAL_THROW_EXTERN_C() -{ - /* Fallback to ordinary osl_getExecutableFile(). */ - return osl_getExecutableFile (ppFileURL); -} - -#endif /* NO_DL_FUNCTIONS */ +#endif /*************************************** CommandArgs_Impl. diff --git a/sal/rtl/source/unload.cxx b/sal/rtl/source/unload.cxx index 76d035eddaac..9d30bb303c26 100644 --- a/sal/rtl/source/unload.cxx +++ b/sal/rtl/source/unload.cxx @@ -42,6 +42,8 @@ using osl::MutexGuard; //---------------------------------------------------------------------------- +#ifndef DISABLE_DYNLOADING + static void rtl_notifyUnloadingListeners(); static sal_Bool isEqualTimeValue ( const TimeValue* time1, const TimeValue* time2) @@ -118,14 +120,23 @@ static osl::Mutex& getUnloadingMutex() return theUnloadingMutex::get(); } +#endif + extern "C" void rtl_moduleCount_acquire(rtl_ModuleCount * that ) { +#ifdef DISABLE_DYNLOADING + (void) that; +#else rtl_StandardModuleCount* pMod= (rtl_StandardModuleCount*)that; osl_incrementInterlockedCount( &pMod->counter); +#endif } extern "C" void rtl_moduleCount_release( rtl_ModuleCount * that ) { +#ifdef DISABLE_DYNLOADING + (void) that; +#else rtl_StandardModuleCount* pMod= (rtl_StandardModuleCount*)that; OSL_ENSURE( pMod->counter >0 , "library counter incorrect" ); osl_decrementInterlockedCount( &pMod->counter); @@ -140,8 +151,10 @@ extern "C" void rtl_moduleCount_release( rtl_ModuleCount * that ) pMod->unusedSince.Nanosec= 0; } } +#endif } +#ifndef DISABLE_DYNLOADING struct hashModule { @@ -176,8 +189,15 @@ static ModuleMap& getModuleMap() return *g_pMap; } +#endif + extern "C" sal_Bool rtl_moduleCount_canUnload( rtl_StandardModuleCount * that, TimeValue * libUnused) { +#ifdef DISABLE_DYNLOADING + (void) that; + (void) libUnused; + return sal_False; +#else if (that->counter == 0) { MutexGuard guard( getUnloadingMutex()); @@ -187,11 +207,16 @@ extern "C" sal_Bool rtl_moduleCount_canUnload( rtl_StandardModuleCount * that, T } } return (that->counter == 0); +#endif } extern "C" sal_Bool SAL_CALL rtl_registerModuleForUnloading( oslModule module) { +#ifdef DISABLE_DYNLOADING + (void) module; + return sal_False; +#else MutexGuard guard( getUnloadingMutex()); ModuleMap& moduleMap= getModuleMap(); sal_Bool ret= sal_True; @@ -219,10 +244,14 @@ extern "C" sal_Bool SAL_CALL rtl_registerModuleForUnloading( oslModule module) ret= sal_False; } return ret; +#endif } extern "C" void SAL_CALL rtl_unregisterModuleForUnloading( oslModule module) { +#ifdef DISABLE_DYNLOADING + (void) module; +#else MutexGuard guard( getUnloadingMutex()); ModuleMap& moduleMap= getModuleMap(); @@ -236,10 +265,14 @@ extern "C" void SAL_CALL rtl_unregisterModuleForUnloading( oslModule module) if( it->second.first == 0) moduleMap.erase( it); } +#endif } extern "C" void SAL_CALL rtl_unloadUnusedModules( TimeValue* libUnused) { +#ifdef DISABLE_DYNLOADING + (void) libUnused; +#else MutexGuard guard( getUnloadingMutex()); typedef std::list< oslModule, rtl::Allocator<oslModule> > list_type; @@ -286,8 +319,10 @@ extern "C" void SAL_CALL rtl_unloadUnusedModules( TimeValue* libUnused) { moduleMap.erase( *un_it); } +#endif } +#ifndef DISABLE_DYNLOADING // ============================================================================== // Unloading Listener Administration @@ -374,32 +409,45 @@ static inline void recycleCookie( sal_Int32 i) } +#endif + // calling the function twice with the same arguments will return tow different cookies. // The listener will then notified twice. extern "C" sal_Int32 SAL_CALL rtl_addUnloadingListener( rtl_unloadingListenerFunc callback, void* _this) { +#ifdef DISABLE_DYNLOADING + (void) callback; + (void) _this; + return 0; +#else MutexGuard guard( getUnloadingMutex()); sal_Int32 cookie= getCookie(); ListenerMap& listenerMap= getListenerMap(); listenerMap[ cookie]= std::make_pair( callback, _this); return cookie; +#endif } extern "C" void SAL_CALL rtl_removeUnloadingListener( sal_Int32 cookie ) { +#ifdef DISABLE_DYNLOADING + (void) cookie; +#else MutexGuard guard( getUnloadingMutex()); ListenerMap& listenerMap= getListenerMap(); size_t removedElements= listenerMap.erase( cookie); if( removedElements ) recycleCookie( cookie); +#endif } +#ifndef DISABLE_DYNLOADING static void rtl_notifyUnloadingListeners() { @@ -411,4 +459,6 @@ static void rtl_notifyUnloadingListeners() } } +#endif + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/textenc.cxx b/sal/textenc/textenc.cxx index 42f1711ecc87..8aeb67a7b243 100644 --- a/sal/textenc/textenc.cxx +++ b/sal/textenc/textenc.cxx @@ -364,7 +364,7 @@ static ImplTextEncodingData const aImplJavaUtf8TextEncodingData namespace { -#if defined IOS || defined ANDROID +#if defined DISABLE_DYNLOADING || defined ANDROID extern "C" ImplTextEncodingData const * sal_getFullTextEncodingData( rtl_TextEncoding); // from tables.cxx in sal_textenc library diff --git a/stoc/source/bootstrap/services.cxx b/stoc/source/bootstrap/services.cxx index e92acad12494..5ddc729a794f 100644 --- a/stoc/source/bootstrap/services.cxx +++ b/stoc/source/bootstrap/services.cxx @@ -118,14 +118,14 @@ static struct ImplementationEntry g_entries[] = extern "C" { -#ifndef IOS +#ifndef DISABLE_DYNLOADING SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_canUnload( TimeValue *pTime ) { return g_moduleCount.canUnload( &g_moduleCount , pTime ); } #endif -#ifdef IOS +#ifdef DISABLE_DYNLOADING #define component_getFactory bootstrap_component_getFactory #endif diff --git a/stoc/source/loader/dllcomponentloader.cxx b/stoc/source/loader/dllcomponentloader.cxx index cd690a23e563..b2327262a472 100644 --- a/stoc/source/loader/dllcomponentloader.cxx +++ b/stoc/source/loader/dllcomponentloader.cxx @@ -229,9 +229,16 @@ sal_Bool SAL_CALL DllComponentLoader::writeRegistryInfo( throw(CannotRegisterImplementationException, RuntimeException) { +#ifdef DISABLE_DYNLOADING + (void) xKey; + (void) rLibName; + OSL_FAIL( "DllComponentLoader::writeRegistryInfo() should not be called I think?" ); + return sal_False; +#else writeSharedLibComponentInfo( expand_url( rLibName ), OUString(), m_xSMgr, xKey ); return sal_True; +#endif } } |