summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2012-10-07 07:45:10 +0300
committerTor Lillqvist <tml@iki.fi>2012-10-07 07:59:14 +0300
commit1691752dd29d661552700d9bcac5d3a3953fb91a (patch)
tree9d00ce644407c938936fe34ed1c9946c08245f64
parent68669491ade83c395144b66a4f65cd7720f76a55 (diff)
When DISABLE_DYNLOADING don't even provide any module loading/unloading API
Will then cause compilation errors where they are used, which will be noticed and taken care of. (The code chanaged to either use direct linking instead, when it makes sense, or to just bypass the functionality that requires dynamic loading.) Much better than waiting until run-time to notice where dynamic loading is attempted. Change-Id: Ib0cb5a2524b5c63f8e27670e7d72e37ce2a8e6e9
-rw-r--r--sal/Module_sal.mk4
-rw-r--r--sal/inc/osl/module.h8
-rw-r--r--sal/inc/osl/module.hxx10
-rw-r--r--sal/osl/all/loadmodulerelative.cxx4
-rw-r--r--sal/osl/unx/module.cxx17
5 files changed, 33 insertions, 10 deletions
diff --git a/sal/Module_sal.mk b/sal/Module_sal.mk
index a144b3c268dc..a2c937d719c5 100644
--- a/sal/Module_sal.mk
+++ b/sal/Module_sal.mk
@@ -52,13 +52,13 @@ $(eval $(call gb_Module_add_targets,sal,\
endif
$(eval $(call gb_Module_add_check_targets,sal,\
- CppunitTest_Module_DLL \
+ $(if $(filter TRUE,$(DISABLE_DYNLOADING)),,CppunitTest_Module_DLL) \
CppunitTest_sal_bytesequence \
CppunitTest_sal_checkapi \
CppunitTest_sal_osl_condition \
$(if $(filter $(OS),WNT),, \
CppunitTest_sal_osl_file) \
- CppunitTest_sal_osl_module \
+ $(if $(filter TRUE,$(DISABLE_DYNLOADING)),,CppunitTest_sal_osl_module) \
CppunitTest_sal_osl_old_test_file \
CppunitTest_sal_osl_security \
CppunitTest_sal_osl_thread \
diff --git a/sal/inc/osl/module.h b/sal/inc/osl/module.h
index f58909909aa2..1a886bfebe8c 100644
--- a/sal/inc/osl/module.h
+++ b/sal/inc/osl/module.h
@@ -70,6 +70,8 @@ typedef void* oslModule;
*/
typedef void ( SAL_CALL *oslGenericFunction )( void );
+#ifndef DISABLE_DYNLOADING
+
/** Load a shared library or module.
@param strModuleName denotes the name of the module to be loaded.
@param nRtldMode denotes the mode.
@@ -129,6 +131,8 @@ SAL_DLLPUBLIC oslModule SAL_CALL osl_loadModuleRelativeAscii(
FullTextEncodingDataSingleton in sal/textenc/textenc.cxx, so can be used
in its implementation without running into circles. */
+#endif
+
/** Retrieve the handle of an already loaded module.
This function can be used to search for a function symbol in the process address space.
@@ -151,10 +155,14 @@ SAL_DLLPUBLIC oslModule SAL_CALL osl_loadModuleRelativeAscii(
*/
SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult);
+#ifndef DISABLE_DYNLOADING
+
/** Release the module
*/
SAL_DLLPUBLIC void SAL_CALL osl_unloadModule(oslModule Module);
+#endif
+
/** lookup the specified symbol name.
@return address of the symbol or NULL if lookup failed.
*/
diff --git a/sal/inc/osl/module.hxx b/sal/inc/osl/module.hxx
index 0d7bca644d92..152db85909f3 100644
--- a/sal/inc/osl/module.hxx
+++ b/sal/inc/osl/module.hxx
@@ -72,16 +72,24 @@ public:
Module(): m_Module(0){}
+#ifndef DISABLE_DYNLOADING
+
Module( const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT) : m_Module(0)
{
load( strModuleName, nRtldMode);
}
+#endif
+
~Module()
{
+#ifndef DISABLE_DYNLOADING
osl_unloadModule(m_Module);
+#endif
}
+#ifndef DISABLE_DYNLOADING
+
sal_Bool SAL_CALL load( const ::rtl::OUString& strModuleName,
sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT)
{
@@ -119,6 +127,8 @@ public:
}
}
+#endif
+
sal_Bool SAL_CALL is() const
{
return m_Module != NULL;
diff --git a/sal/osl/all/loadmodulerelative.cxx b/sal/osl/all/loadmodulerelative.cxx
index f3ea7bfe3509..6b7cf0e43b17 100644
--- a/sal/osl/all/loadmodulerelative.cxx
+++ b/sal/osl/all/loadmodulerelative.cxx
@@ -43,6 +43,8 @@
extern "C" {
+#ifndef DISABLE_DYNLOADING
+
oslModule SAL_CALL osl_loadModuleRelative(
oslGenericFunction const baseModule, rtl_uString * const relativePath,
sal_Int32 const mode)
@@ -67,6 +69,8 @@ oslModule SAL_CALL osl_loadModuleRelative(
return ::osl_loadModule(abs.pData, mode);
}
+#endif // !DISABLE_DYNLOADING
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/unx/module.cxx b/sal/osl/unx/module.cxx
index 386aa0b1c2a9..ed2f675c6858 100644
--- a/sal/osl/unx/module.cxx
+++ b/sal/osl/unx/module.cxx
@@ -118,6 +118,9 @@ static sal_Bool getModulePathFromAddress(void * address, rtl_String ** path) {
return result;
}
+
+#ifndef DISABLE_DYNLOADING
+
/*****************************************************************************/
/* osl_loadModule */
/*****************************************************************************/
@@ -157,7 +160,6 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR
"sal.osl", "only either LAZY or NOW");
if (pModuleName)
{
-#ifndef DISABLE_DYNLOADING
#ifdef ANDROID
(void) nRtldMode;
void *pLib = lo_dlopen(pModuleName);
@@ -173,11 +175,6 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR
<< dlerror());
#endif
return ((oslModule)(pLib));
-
-#else /* DISABLE_DYNLOADING */
- (void) nRtldMode;
- fprintf(stderr, "No DL Functions, osl_loadModuleAscii(%s) does nothing\n", pModuleName);
-#endif /* DISABLE_DYNLOADING */
}
return NULL;
}
@@ -212,6 +209,8 @@ oslModule osl_loadModuleRelativeAscii(
}
}
+#endif // !DISABLE_DYNLOADING
+
/*****************************************************************************/
/* osl_getModuleHandle */
/*****************************************************************************/
@@ -227,6 +226,8 @@ osl_getModuleHandle(rtl_uString *, oslModule *pResult)
return sal_True;
}
+#ifndef DISABLE_DYNLOADING
+
/*****************************************************************************/
/* osl_unloadModule */
/*****************************************************************************/
@@ -234,7 +235,6 @@ void SAL_CALL osl_unloadModule(oslModule hModule)
{
if (hModule)
{
-#ifndef DISABLE_DYNLOADING
#ifdef ANDROID
int nRet = lo_dlclose(hModule);
#else
@@ -242,10 +242,11 @@ void SAL_CALL osl_unloadModule(oslModule hModule)
#endif
SAL_INFO_IF(
nRet != 0, "sal.osl", "dlclose(" << hModule << "): " << dlerror());
-#endif /* ifndef DISABLE_DYNLOADING */
}
}
+#endif // !DISABLE_DYNLOADING
+
/*****************************************************************************/
/* osl_getSymbol */
/*****************************************************************************/