diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-03-12 11:52:26 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-03-12 11:54:26 +0100 |
commit | 25292b154ecfb33450307357f006b652cd673967 (patch) | |
tree | cabec964404bd6d63c1fbc24d9feaa2ecce00a19 /sal | |
parent | 5eee7de29362ecd00d43ed9eb9ed7230606dc92a (diff) |
module.c -> module.cxx, use sal/log.hxx
Diffstat (limited to 'sal')
-rw-r--r-- | sal/Library_sal.mk | 2 | ||||
-rw-r--r-- | sal/osl/unx/module.cxx (renamed from sal/osl/unx/module.c) | 62 |
2 files changed, 28 insertions, 36 deletions
diff --git a/sal/Library_sal.mk b/sal/Library_sal.mk index ed738d774fec..f573bfa96bb7 100644 --- a/sal/Library_sal.mk +++ b/sal/Library_sal.mk @@ -159,6 +159,7 @@ $(eval $(call gb_Library_add_exception_objects,sal,\ sal/osl/unx/file_stat \ sal/osl/unx/file_url \ sal/osl/unx/file_volume \ + sal/osl/unx/module \ sal/osl/unx/process \ sal/osl/unx/process_impl \ sal/osl/unx/salinit \ @@ -166,7 +167,6 @@ $(eval $(call gb_Library_add_exception_objects,sal,\ )) $(eval $(call gb_Library_add_cobjects,sal,\ sal/osl/unx/diagnose \ - sal/osl/unx/module \ sal/osl/unx/mutex \ sal/osl/unx/nlsupport \ sal/osl/unx/pipe \ diff --git a/sal/osl/unx/module.c b/sal/osl/unx/module.cxx index ea41a7e9b9b4..e5e91e67814b 100644 --- a/sal/osl/unx/module.c +++ b/sal/osl/unx/module.cxx @@ -26,8 +26,10 @@ * ************************************************************************/ +#include "sal/config.h" + +#include <sal/log.hxx> #include <sal/types.h> -#include <osl/diagnose.h> #include <osl/module.h> #include <osl/thread.h> #include <osl/process.h> @@ -35,10 +37,6 @@ #include "system.h" -#if OSL_DEBUG_LEVEL > 1 -#include <stdio.h> -#endif - #ifdef AIX #include <sys/ldr.h> #endif @@ -48,7 +46,7 @@ #endif /* implemented in file.c */ -extern int UnicodeToText(char *, size_t, const sal_Unicode *, sal_Int32); +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; @@ -130,7 +128,7 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *ustrModuleName, sal_Int32 nRtldMo oslModule pModule=0; rtl_uString* ustrTmp = NULL; - OSL_ENSURE(ustrModuleName,"osl_loadModule : string is not valid"); + SAL_WARN_IF(ustrModuleName == 0, "sal.osl", "string is not valid"); /* ensure ustrTmp hold valid string */ if (osl_File_E_None != osl_getSystemPathFromFileURL(ustrModuleName, &ustrTmp)) @@ -154,9 +152,10 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *ustrModuleName, sal_Int32 nRtldMo oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nRtldMode) { - OSL_ASSERT( - (nRtldMode & SAL_LOADMODULE_LAZY) == 0 || - (nRtldMode & SAL_LOADMODULE_NOW) == 0); /* only either LAZY or NOW */ + SAL_WARN_IF( + ((nRtldMode & SAL_LOADMODULE_LAZY) != 0 + && (nRtldMode & SAL_LOADMODULE_NOW) != 0), + "sal.osl", "only either LAZY or NOW"); if (pModuleName) { #ifndef NO_DL_FUNCTIONS @@ -169,10 +168,10 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR ((nRtldMode & SAL_LOADMODULE_GLOBAL) ? RTLD_GLOBAL : RTLD_LOCAL); void* pLib = dlopen(pModuleName, rtld_mode); #endif -#if OSL_DEBUG_LEVEL > 1 - if (pLib == 0) - OSL_TRACE("Error osl_loadModule: %s", dlerror()); -#endif /* OSL_DEBUG_LEVEL */ + SAL_INFO_IF( + pLib == 0, "sal.osl", + "dlopen(" << pModuleName << ", " << rtld_mode << "): " + << dlerror()); return ((oslModule)(pLib)); @@ -187,14 +186,16 @@ oslModule SAL_CALL osl_loadModuleAscii(const sal_Char *pModuleName, sal_Int32 nR oslModule osl_loadModuleRelativeAscii( oslGenericFunction baseModule, char const * relativePath, sal_Int32 mode) { - OSL_ASSERT(relativePath != NULL); + SAL_WARN_IF(relativePath == 0, "sal.osl", "illegal argument"); if (relativePath[0] == '/') { return osl_loadModuleAscii(relativePath, mode); } else { rtl_String * path = NULL; rtl_String * suffix = NULL; oslModule module; - if (!getModulePathFromAddress(baseModule, &path)) { + if (!getModulePathFromAddress( + reinterpret_cast< void * >(baseModule), &path)) + { return NULL; } rtl_string_newFromStr_WithLength( @@ -217,9 +218,8 @@ oslModule osl_loadModuleRelativeAscii( /*****************************************************************************/ sal_Bool SAL_CALL -osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult) +osl_getModuleHandle(rtl_uString *, oslModule *pResult) { - (void) pModuleName; /* avoid warning about unused parameter */ #if !defined(NO_DL_FUNCTIONS) || defined(IOS) *pResult = (oslModule) RTLD_DEFAULT; #else @@ -241,16 +241,8 @@ void SAL_CALL osl_unloadModule(oslModule hModule) #else int nRet = dlclose(hModule); #endif - -#if OSL_DEBUG_LEVEL > 1 - if (nRet != 0) - { - fprintf(stderr, "Error osl_unloadModule: %s\n", dlerror()); - } -#else - (void) nRet; -#endif /* if OSL_DEBUG_LEVEL */ - + SAL_INFO_IF( + nRet != 0, "sal.osl", "dlclose(" << hModule << "): " << dlerror()); #endif /* ifndef NO_DL_FUNCTIONS */ } } @@ -278,9 +270,9 @@ osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol) if (pSymbol) { fcnAddr = dlsym(Module, pSymbol); - - if (!fcnAddr) - OSL_TRACE("Error osl_getAsciiFunctionSymbol: %s", dlerror()); + SAL_INFO_IF( + fcnAddr == 0, "sal.osl", + "dlsym(" << Module << ", " << pSymbol << "): " << dlerror()); } #endif @@ -328,16 +320,16 @@ sal_Bool SAL_CALL osl_getModuleURLFromAddress(void * addr, rtl_uString ** ppLibr osl_getProcessWorkingDir(&workDir); if (workDir) { -#if OSL_DEBUG_LEVEL > 1 - OSL_TRACE("module.c::osl_getModuleURLFromAddress - %s", path->buffer); -#endif + SAL_INFO( + "sal.osl", "osl_getModuleURLFromAddress: " << path->buffer); rtl_string2UString(ppLibraryUrl, path->buffer, path->length, osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS); - OSL_ASSERT(*ppLibraryUrl != NULL); + SAL_WARN_IF( + *ppLibraryUrl == 0, "sal.osl", "rtl_string2UString failed"); osl_getFileURLFromSystemPath(*ppLibraryUrl, ppLibraryUrl); osl_getAbsoluteFileURL(workDir, *ppLibraryUrl, ppLibraryUrl); |