This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch devs/devilhorns/apos
in repository efl.

View the commit online.

commit 6054a69eb8a16d4e141a0ca404900404fd124311
Author: Christopher Michael <devilho...@comcast.net>
AuthorDate: Tue Aug 16 10:09:01 2022 -0400

    ecore_drm2: Add code to dlopen & symlink needed libdrm functions
---
 src/lib/ecore_drm2/ecore_drm2.c | 56 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/src/lib/ecore_drm2/ecore_drm2.c b/src/lib/ecore_drm2/ecore_drm2.c
index d1eacfafe5..384afa621e 100644
--- a/src/lib/ecore_drm2/ecore_drm2.c
+++ b/src/lib/ecore_drm2/ecore_drm2.c
@@ -2,10 +2,59 @@
 
 /* local variables */
 static int _ecore_drm2_init_count = 0;
+static void *_drm_lib = NULL;
 
 /* external variables */
 int _ecore_drm2_log_dom = -1;
 
+/* local static functions */
+static Eina_Bool
+_ecore_drm2_link(void)
+{
+   int i;
+   Eina_Bool fail = EINA_FALSE;
+   const char *drm_libs[] =
+     {
+        "libdrm.so.2",
+        "libdrm.so.1",
+        "libdrm.so.0",
+        "libdrm.so",
+        NULL,
+     };
+
+#define SYM(lib, xx)                         \
+   do {                                      \
+      sym_ ## xx = dlsym(lib, #xx);          \
+      if (!(sym_ ## xx)) {                   \
+         fail = EINA_TRUE;                   \
+      }                                      \
+   } while (0)
+
+   if (_drm_lib) return EINA_TRUE;
+
+   for (i = 0; drm_libs[i]; i++)
+     {
+        _drm_lib = dlopen(drm_libs[i], RTLD_LOCAL | RTLD_LAZY);
+        if (!_drm_lib) continue;
+
+        fail = EINA_FALSE;
+
+        /* TODO: Sym needed libdrm functions */
+
+        if (fail)
+          {
+             dlclose(_drm_lib);
+             _drm_lib = NULL;
+          }
+        else
+          break;
+     }
+
+   if (!_drm_lib) return EINA_FALSE;
+   return EINA_TRUE;
+}
+
+/* API functions */
 EAPI int
 ecore_drm2_init(void)
 {
@@ -39,8 +88,13 @@ ecore_drm2_init(void)
         goto log_err;
      }
 
+   if (!_ecore_drm2_link()) goto link_err;
+
    return _ecore_drm2_init_count;
 
+link_err:
+   eina_log_domain_unregister(_ecore_drm2_log_dom);
+   _ecore_drm2_log_dom = -1;
 log_err:
    elput_shutdown();
 elput_err:
@@ -64,6 +118,8 @@ ecore_drm2_shutdown(void)
 
    if (--_ecore_drm2_init_count != 0) return _ecore_drm2_init_count;
 
+   dlclose(_drm_lib);
+
    eina_log_domain_unregister(_ecore_drm2_log_dom);
    _ecore_drm2_log_dom = -1;
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to