eina: make it possible to load module symbol into the global namespace.
authorCedric BAIL <c.bail@partner.samsung.com>
Fri, 11 Jul 2014 10:13:02 +0000 (12:13 +0200)
committerCedric BAIL <c.bail@partner.samsung.com>
Fri, 11 Jul 2014 13:32:51 +0000 (15:32 +0200)
src/lib/eina/eina_module.c
src/lib/eina/eina_module.h

index 29b6802..2c92603 100644 (file)
@@ -92,6 +92,9 @@ struct _Eina_Module
 {
    void *handle;
    int ref;
+
+   Eina_Bool global;
+
    const char file[];
 };
 
@@ -304,7 +307,11 @@ EAPI Eina_Bool eina_module_load(Eina_Module *m)
       goto loaded;
 
    if (getenv("EINA_MODULE_LAZY_LOAD")) flag = RTLD_LAZY;
+
+   if (m->global) flag |= RTLD_GLOBAL;
    dl_handle = dlopen(m->file, flag);
+   if (m->global) flag &= ~RTLD_GLOBAL;
+
    if (!dl_handle)
      {
         WRN("could not dlopen(\"%s\", %s): %s", m->file, dlerror(), 
@@ -383,6 +390,11 @@ EAPI const char *eina_module_file_get(const Eina_Module *m)
    return m->file;
 }
 
+EAPI void eina_module_global_set(Eina_Module *module, Eina_Bool global)
+{
+   module->global = !!global;
+}
+
 EAPI char *eina_module_symbol_path_get(const void *symbol, const char *sub_dir)
 {
 #ifdef HAVE_DLADDR
index 6f9b08e..f48ca27 100644 (file)
@@ -205,6 +205,13 @@ EAPI void *
 EAPI const char *
  eina_module_file_get(const Eina_Module *module) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
 
+/**
+ * @brief Define if on module load we should expose all symbol
+ *
+ * @param module The module to turn off/on symbol to be exposed
+ * @since 1.11
+ */
+EAPI void eina_module_global_set(Eina_Module *module, Eina_Bool global) EINA_ARG_NONNULL(1);
 
 /**
  * @brief Return the path built from the location of a library and a