]> xenbits.xensource.com Git - libvirt.git/commitdiff
driver: conditionalize use of dlopen functions & use mingw-dlfcn
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 2 Aug 2017 10:21:12 +0000 (11:21 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 2 Aug 2017 12:51:28 +0000 (13:51 +0100)
Not every platform is guaranteed to have dlopen/dlsym, so we should
conditionalize its use. Suprisingly it is actually present for Win32
via the mingw-dlfcn add on, but we should still conditionalize it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
mingw-libvirt.spec.in
src/driver.c

index 4efa0ddbfa32f6ea5dacd88ac21f79f91aa263ad..183346cf64e3cfb07903ae05fbd3a8be55a8c13b 100644 (file)
@@ -54,6 +54,8 @@ BuildRequires:  mingw32-libxml2
 BuildRequires:  mingw64-libxml2
 BuildRequires:  mingw32-portablexdr
 BuildRequires:  mingw64-portablexdr
+BuildRequires:  mingw32-dlfcn
+BuildRequires:  mingw64-dlfcn
 
 BuildRequires:  pkgconfig
 # Need native version for msgfmt
index 2e7dd01df8877b97fd53a4819cabd793f15aba00..04dd0a44318bfe0eb264d29501ba6a1084409f2d 100644 (file)
@@ -34,10 +34,11 @@ VIR_LOG_INIT("driver");
 
 
 /* XXX re-implement this for other OS, or use libtools helper lib ? */
-
-#include <dlfcn.h>
 #define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver"
 
+#ifdef HAVE_DLFCN_H
+# include <dlfcn.h>
+
 
 static void *
 virDriverLoadModuleFile(const char *file)
@@ -126,6 +127,19 @@ virDriverLoadModuleFull(const char *path,
     return ret;
 }
 
+#else /* ! HAVE_DLFCN_H */
+int
+virDriverLoadModuleFull(const char *path ATTRIBUTE_UNUSED,
+                        const char *regfunc ATTRIBUTE_UNUSED,
+                        void **handle)
+{
+    VIR_DEBUG("dlopen not available on this platform");
+    if (handle)
+        *handle = NULL;
+    return -1;
+}
+#endif /* ! HAVE_DLFCN_H */
+
 
 int
 virDriverLoadModule(const char *name,