aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/dlopen.h
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-08-27 08:17:50 +0200
committermarha <marha@users.sourceforge.net>2012-08-27 08:17:50 +0200
commitb3462c12542a69eeaa3fe90fddfbb15d30c18158 (patch)
tree294230cca0e59ee250cd70060ba3f8c3742b4023 /mesalib/src/mesa/main/dlopen.h
parente91ed68959d63f79e3b4973bc80c7ebcd07ed021 (diff)
downloadvcxsrv-b3462c12542a69eeaa3fe90fddfbb15d30c18158.tar.gz
vcxsrv-b3462c12542a69eeaa3fe90fddfbb15d30c18158.tar.bz2
vcxsrv-b3462c12542a69eeaa3fe90fddfbb15d30c18158.zip
xwininfo fontconfig libX11 libXau libXext libxcb mesa pixman
xkeyboard-config git update 27 Aug 2012
Diffstat (limited to 'mesalib/src/mesa/main/dlopen.h')
-rw-r--r--mesalib/src/mesa/main/dlopen.h83
1 files changed, 75 insertions, 8 deletions
diff --git a/mesalib/src/mesa/main/dlopen.h b/mesalib/src/mesa/main/dlopen.h
index 9895a2254..a5366a14e 100644
--- a/mesalib/src/mesa/main/dlopen.h
+++ b/mesalib/src/mesa/main/dlopen.h
@@ -25,18 +25,85 @@
#ifndef DLOPEN_H
#define DLOPEN_H
+/**
+ * Wrapper functions for dlopen(), dlsym(), dlclose().
+ * Note that the #ifdef tests for various environments should be expanded.
+ */
-typedef void (*GenericFunc)(void);
-
+#if defined(HAVE_DLOPEN)
+#include <dlfcn.h>
+#endif
+#if defined(_WIN32)
+#include <windows.h>
+#endif
-extern void *
-_mesa_dlopen(const char *libname, int flags);
+typedef void (*GenericFunc)(void);
-extern GenericFunc
-_mesa_dlsym(void *handle, const char *fname);
+/**
+ * Wrapper for dlopen().
+ * Note that 'flags' isn't used at this time.
+ */
+static inline void *
+_mesa_dlopen(const char *libname, int flags)
+{
+#if defined(__blrts)
+ return NULL;
+#elif defined(HAVE_DLOPEN)
+ flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */
+ return dlopen(libname, flags);
+#elif defined(__MINGW32__)
+ return LoadLibraryA(libname);
+#else
+ return NULL;
+#endif
+}
-extern void
-_mesa_dlclose(void *handle);
+/**
+ * Wrapper for dlsym() that does a cast to a generic function type,
+ * rather than a void *. This reduces the number of warnings that are
+ * generated.
+ */
+static inline GenericFunc
+_mesa_dlsym(void *handle, const char *fname)
+{
+ union {
+ void *v;
+ GenericFunc f;
+ } u;
+#if defined(__blrts)
+ u.v = NULL;
+#elif defined(__DJGPP__)
+ /* need '_' prefix on symbol names */
+ char fname2[1000];
+ fname2[0] = '_';
+ strncpy(fname2 + 1, fname, 998);
+ fname2[999] = 0;
+ u.v = dlsym(handle, fname2);
+#elif defined(HAVE_DLOPEN)
+ u.v = dlsym(handle, fname);
+#elif defined(__MINGW32__)
+ u.v = (void *) GetProcAddress(handle, fname);
+#else
+ u.v = NULL;
+#endif
+ return u.f;
+}
+/**
+ * Wrapper for dlclose().
+ */
+static inline void
+_mesa_dlclose(void *handle)
+{
+#if defined(__blrts)
+ (void) handle;
+#elif defined(HAVE_DLOPEN)
+ dlclose(handle);
+#elif defined(__MINGW32__)
+ FreeLibrary(handle);
+#else
+ (void) handle;
+#endif
+}
#endif