diff options
| author | Soren Jorvang <soren.jorvang@gmail.com> | 2011-01-29 04:52:19 +0000 |
|---|---|---|
| committer | Soren Jorvang <soren.jorvang@gmail.com> | 2011-01-29 04:52:19 +0000 |
| commit | 1bcad428eacd4931d62374f0f4ad349b2a6eff48 (patch) | |
| tree | 053c7e7b5f3c89bba2871bc8698339d5b0def145 /Source/Core/Common/Src/DynamicLibrary.cpp | |
| parent | 4c58c7ea031d518f3bbb936fc8f97fa2aad878a3 (diff) | |
Link the video plugin statically into the main binary on OS X.
This makes the OS X build more robust and should help pave the
way for the integration of the video plugins as well as LTO.
There are now no more global class level namespace conflicts left,
as evidenced by the fact that Dolphin can be linked with -all_load,
not that you would want to.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6958 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/DynamicLibrary.cpp')
| -rw-r--r-- | Source/Core/Common/Src/DynamicLibrary.cpp | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/Source/Core/Common/Src/DynamicLibrary.cpp b/Source/Core/Common/Src/DynamicLibrary.cpp index ff2833a6b4..401c7bc993 100644 --- a/Source/Core/Common/Src/DynamicLibrary.cpp +++ b/Source/Core/Common/Src/DynamicLibrary.cpp @@ -76,17 +76,20 @@ int DynamicLibrary::Load(const char* filename) #ifdef _WIN32 library = LoadLibrary(filename); -#else +#elif defined __linux__ // RTLD_NOW: resolve all symbols on load // RTLD_LOCAL: don't resolve symbols for other libraries library = dlopen(filename, RTLD_NOW | RTLD_LOCAL); +#else + library = RTLD_SELF; + return 1; #endif DEBUG_LOG(COMMON, "DL: LoadLibrary: %s(%p)", filename, library); if (!library) { ERROR_LOG(COMMON, "DL: Error loading DLL %s: %s", filename, - DllGetLastError()); + DllGetLastError()); return 0; } @@ -104,33 +107,35 @@ int DynamicLibrary::Load(const char* filename) int DynamicLibrary::Unload() { INFO_LOG(COMMON, "DL: Unloading dynamic library %s", library_file.c_str()); - int retval; - if (!IsLoaded()) { // library != null + int retval; + if (!IsLoaded()) { // library != null ERROR_LOG(COMMON, "DL: Unload failed for %s: not loaded", - library_file.c_str()); - PanicAlert("DL: Unload failed %s: not loaded", - library_file.c_str()); - return 0; - } - - DEBUG_LOG(COMMON, "DL: FreeLibrary: %s %p\n", - library_file.c_str(), library); + library_file.c_str()); + PanicAlert("DL: Unload failed %s: not loaded", + library_file.c_str()); + return 0; + } + + DEBUG_LOG(COMMON, "DL: FreeLibrary: %s %p\n", + library_file.c_str(), library); #ifdef _WIN32 - retval = FreeLibrary(library); + retval = FreeLibrary(library); #else - retval = dlclose(library)?0:1; + if (library == RTLD_SELF) + return 1; + else + retval = dlclose(library) ? 0 : 1; #endif - if (! retval) { - ERROR_LOG(COMMON, "DL: Unload failed %s: %s", - library_file.c_str(), - DllGetLastError()); - } - library = 0; + if (! retval) { + ERROR_LOG(COMMON, "DL: Unload failed %s: %s", + library_file.c_str(), DllGetLastError()); + } + library = 0; INFO_LOG(COMMON, "DL: Done unloading dynamic library %s", library_file.c_str()); - return retval; + return retval; } // Returns the address where symbol funcname is loaded or NULL on failure @@ -156,11 +161,10 @@ void* DynamicLibrary::Get(const char* funcname) const if (!retval) { WARN_LOG(COMMON, "DL: Symbol %s missing in %s (error: %s)\n", - funcname, library_file.c_str(), - DllGetLastError()); + funcname, library_file.c_str(), DllGetLastError()); } INFO_LOG(COMMON, "DL: Done getting symbol %s: %s", library_file.c_str(), - funcname); + funcname); return retval; } |
