driver: conditionalize use of dlopen functions & use mingw-dlfcn

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>
This commit is contained in:
Daniel P. Berrange 2017-08-02 11:21:12 +01:00
parent 376cfc2a81
commit 8b9d017de3
2 changed files with 18 additions and 2 deletions

View 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

View 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,