From 12456995e992b3eb1ea1b9427693fd691830beb8 Mon Sep 17 00:00:00 2001 From: kakaroto Date: Sat, 5 Nov 2011 17:49:04 +0000 Subject: [PATCH] Elementary: Make elm_module use eina_module instead of dl* directly git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@64774 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/Elementary.h.in | 1 - src/lib/elm_module.c | 57 +++++++++++++++++++++++++++++-------------------- src/lib/elm_priv.h | 2 +- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index b559937..7623779 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -327,7 +327,6 @@ contact with the developers and maintainers. #include #include #include -#include #include #include #include diff --git a/src/lib/elm_module.c b/src/lib/elm_module.c index b725f87..4b67b52 100644 --- a/src/lib/elm_module.c +++ b/src/lib/elm_module.c @@ -29,8 +29,6 @@ # include "elementary_config.h" #endif -#include /* dlopen,dlclose,etc */ - static Eina_Hash *modules = NULL; static Eina_Hash *modules_as = NULL; @@ -112,19 +110,19 @@ _elm_module_load(Elm_Module *m) const char *home; char buf[PATH_MAX]; - if (m->handle) return EINA_TRUE; + if (m->module) return EINA_TRUE; home = getenv("HOME"); if (home) { snprintf(buf, sizeof(buf), "%s/.elementary/modules/%s/%s/module" EFL_SHARED_EXTENSION, home, m->name, MODULE_ARCH); - m->handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL); - if (m->handle) + m->module = eina_module_new(buf); + if (m->module && eina_module_load (m->module) == EINA_TRUE) { - m->init_func = dlsym(m->handle, "elm_modapi_init"); + m->init_func = eina_module_symbol_get(m->module, "elm_modapi_init"); if (m->init_func) { - m->shutdown_func = dlsym(m->handle, "elm_modapi_shutdown"); + m->shutdown_func = eina_module_symbol_get(m->module, "elm_modapi_shutdown"); m->so_path = eina_stringshare_add(buf); snprintf(buf, sizeof(buf), "%s/.elementary/modules/%s/%s", home, m->name, MODULE_ARCH); m->bin_dir = eina_stringshare_add(buf); @@ -133,26 +131,32 @@ _elm_module_load(Elm_Module *m) } else { - if (m->handle) + if (m->module) { - dlclose(m->handle); - m->handle = NULL; + eina_module_unload(m->module); + eina_module_free(m->module); + m->module = NULL; } return EINA_FALSE; } } + else if (m->module) + { + eina_module_free(m->module); + m->module = NULL; + } } - if (!m->handle) + if (!m->module) { snprintf(buf, sizeof(buf), "%s/elementary/modules/%s/%s/module" EFL_SHARED_EXTENSION, _elm_lib_dir, m->name, MODULE_ARCH); - m->handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL); - if (m->handle) + m->module = eina_module_new(buf); + if (m->module && eina_module_load (m->module) == EINA_TRUE) { - m->init_func = dlsym(m->handle, "elm_modapi_init"); + m->init_func = eina_module_symbol_get(m->module, "elm_modapi_init"); if (m->init_func) { - m->shutdown_func = dlsym(m->handle, "elm_modapi_shutdown"); + m->shutdown_func = eina_module_symbol_get(m->module, "elm_modapi_shutdown"); m->so_path = eina_stringshare_add(buf); snprintf(buf, sizeof(buf), "%s/elementary/modules/%s/%s", _elm_lib_dir, m->name, MODULE_ARCH); m->bin_dir = eina_stringshare_add(buf); @@ -161,17 +165,23 @@ _elm_module_load(Elm_Module *m) } else { - if (m->handle) + if (m->module) { - dlclose(m->handle); - m->handle = NULL; + eina_module_unload(m->module); + eina_module_free(m->module); + m->module = NULL; } return EINA_FALSE; } } } + else if (m->module) + { + eina_module_free(m->module); + m->module = NULL; + } - if (!m->handle) return EINA_FALSE; + if (!m->module) return EINA_FALSE; return EINA_TRUE; } @@ -186,11 +196,12 @@ _elm_module_unload(Elm_Module *m) free(m->api); m->api = NULL; } - if (m->handle) + if (m->module) { if (m->shutdown_func) m->shutdown_func(m); - dlclose(m->handle); - m->handle = NULL; + eina_module_unload(m->module); + eina_module_free(m->module); + m->module = NULL; } m->shutdown_func = NULL; m->init_func = NULL; @@ -236,5 +247,5 @@ _elm_module_del(Elm_Module *m) const void * _elm_module_symbol_get(Elm_Module *m, const char *name) { - return dlsym(m->handle, name); + return eina_module_symbol_get(m->module, name); } diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h index 7ca19f1..e610fa3 100644 --- a/src/lib/elm_priv.h +++ b/src/lib/elm_priv.h @@ -168,7 +168,7 @@ struct _Elm_Module const char *so_path; const char *data_dir; const char *bin_dir; - void *handle; + Eina_Module *module; void *data; void *api; int (*init_func) (Elm_Module *m); -- 2.7.4