[Scummvm-cvs-logs] SF.net SVN: scummvm:[51677] scummvm/branches/gsoc2010-plugins/backends/ plugins
toneman1138 at users.sourceforge.net
toneman1138 at users.sourceforge.net
Tue Aug 3 08:25:03 CEST 2010
Revision: 51677
http://scummvm.svn.sourceforge.net/scummvm/?rev=51677&view=rev
Author: toneman1138
Date: 2010-08-03 06:25:03 +0000 (Tue, 03 Aug 2010)
Log Message:
-----------
got rid of dlopen, dlclose, etc. wrappers
Modified Paths:
--------------
scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.h
scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp
Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp 2010-08-03 03:14:35 UTC (rev 51676)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp 2010-08-03 06:25:03 UTC (rev 51677)
@@ -448,46 +448,5 @@
return NULL;
}
-
-static char dlerr[MAXDLERRLEN];
-
-void *dlopen(const char *filename, int flags) {
- DLObject *obj = new DLObject(dlerr);
- if (obj->open(filename))
- return (void *)obj;
- delete obj;
- return NULL;
-}
-
-int dlclose(void *handle) {
- DLObject *obj = (DLObject *)handle;
- if (obj == NULL) {
- strcpy(dlerr, "Handle is NULL.");
- return -1;
- }
- if (obj->close()) {
- delete obj;
- return 0;
- }
- return -1;
-}
-
-void *dlsym(void *handle, const char *symbol) {
- if (handle == NULL) {
- strcpy(dlerr, "Handle is NULL.");
- return NULL;
- }
- return ((DLObject *)handle)->symbol(symbol);
-}
-
-const char *dlerror() {
- return dlerr;
-}
-
-void dlforgetsyms(void *handle) {
- if (handle != NULL)
- ((DLObject *)handle)->discard_symtab();
-}
-
#endif /* DYNAMIC_MODULES */
Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.h 2010-08-03 03:14:35 UTC (rev 51676)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.h 2010-08-03 06:25:03 UTC (rev 51677)
@@ -93,7 +93,6 @@
extern "C" {
void *dlopen(const char *filename, int flags);
int dlclose(void *handle);
- void *dlsym(void *handle, const char *symbol);
const char *dlerror();
void dlforgetsyms(void *handle);
}
Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp 2010-08-03 03:14:35 UTC (rev 51676)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp 2010-08-03 06:25:03 UTC (rev 51677)
@@ -31,6 +31,7 @@
#include "backends/plugins/elf-loader.h"
+static char dlerr[MAXDLERRLEN];
class ELFPlugin : public DynamicPlugin {
protected:
@@ -38,9 +39,15 @@
Common::String _filename;
virtual VoidFunc findSymbol(const char *symbol) {
- void *func = dlsym(_dlHandle, symbol);
+ void *func;
+ if (_dlHandle == NULL) {
+ strcpy(dlerr, "Handle is NULL.");
+ func = NULL;
+ } else {
+ func = ((DLObject *)_dlHandle)->symbol(symbol);
+ }
if (!func)
- warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.c_str(), dlerror());
+ warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.c_str(), dlerr);
// FIXME HACK: This is a HACK to circumvent a clash between the ISO C++
// standard and POSIX: ISO C++ disallows casting between function pointers
@@ -62,17 +69,25 @@
bool loadPlugin() {
assert(!_dlHandle);
- _dlHandle = dlopen(_filename.c_str(), RTLD_LAZY);
+ DLObject *obj = new DLObject(dlerr);
+ if (obj->open(_filename.c_str())) {
+ _dlHandle = (void *)obj;
+ } else {
+ delete obj;
+ _dlHandle = NULL;
+ }
if (!_dlHandle) {
- warning("Failed loading plugin '%s' (%s)", _filename.c_str(), dlerror());
+ warning("Failed loading plugin '%s' (%s)", _filename.c_str(), dlerr);
return false;
}
bool ret = DynamicPlugin::loadPlugin();
- if (ret)
- dlforgetsyms(_dlHandle);
+ if (ret) {
+ if (_dlHandle != NULL)
+ ((DLObject *)_dlHandle)->discard_symtab();
+ }
return ret;
}
@@ -80,8 +95,15 @@
void unloadPlugin() {
DynamicPlugin::unloadPlugin();
if (_dlHandle) {
- if (dlclose(_dlHandle) != 0)
- warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());
+ DLObject *obj = (DLObject *)_dlHandle;
+ if (obj == NULL) {
+ strcpy(dlerr, "Handle is NULL.");
+ warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerr);
+ } else if (obj->close()) {
+ delete obj;
+ } else {
+ warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerr);
+ }
_dlHandle = 0;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list