summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2012-03-19 18:43:59 +0200
committerTor Lillqvist <tml@iki.fi>2012-03-21 00:00:05 +0200
commit128749140ffc6165f0bbbf34da3b5461c541b32f (patch)
tree844617bcaf03e4fa27e18217490739a890354792 /sal
parentc0ab229dc74e116760866f27b5df12e76430aef5 (diff)
More hacking on static linking (iOS) support
Diffstat (limited to 'sal')
-rw-r--r--sal/Library_sal.mk1
-rw-r--r--sal/cppunittester/cppunittester.cxx4
-rw-r--r--sal/inc/cppunittester/protectorfactory.hxx2
-rw-r--r--sal/osl/unx/module.cxx22
-rw-r--r--sal/osl/unx/process_impl.cxx14
-rw-r--r--sal/rtl/source/unload.cxx50
-rw-r--r--sal/textenc/textenc.cxx2
7 files changed, 66 insertions, 29 deletions
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