From: Brian Paul Date: Wed, 11 Jun 2008 17:37:46 +0000 (-0600) Subject: egl: some prototype Windows code (eq for dlopen,dlsym) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6b389b5c2facc431af0ffb21e3a9bcd532765367;p=mesa.git egl: some prototype Windows code (eq for dlopen,dlsym) --- diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 92c529911c1..5ecfb9eb306 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -5,7 +5,6 @@ #include #include -#include #include #include #include "eglconfig.h" @@ -22,6 +21,7 @@ #include "eglsurface.h" #if defined(_EGL_PLATFORM_X) +#include #include "eglx.h" #elif defined(_EGL_PLATFORM_WINDOWS) /* XXX to do */ @@ -165,39 +165,70 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args) { _EGLDriver *drv; _EGLMain_t mainFunc; +#if defined(_EGL_PLATFORM_WINDOWS) + HMODULE lib; +#elif defined(_EGL_PLATFORM_X) void *lib; +#endif char driverFilename[1000]; assert(driverName); +#if defined(_EGL_PLATFORM_WINDOWS) + /* XXX untested */ + sprintf(driverFilename, "%s.dll", driverName); + _eglLog(_EGL_DEBUG, "dlopen(%s)", driverFilename); + lib = LoadLibrary(driverFilename); +#elif defined(_EGL_PLATFORM_X) /* XXX also prepend a directory path??? */ sprintf(driverFilename, "%s.so", driverName); - _eglLog(_EGL_DEBUG, "dlopen(%s)", driverFilename); lib = dlopen(driverFilename, RTLD_NOW); +#endif + if (!lib) { _eglLog(_EGL_WARNING, "Could not open %s (%s)", driverFilename, dlerror()); return NULL; } +#if defined(_EGL_PLATFORM_WINDOWS) + mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain"); +#elif defined(_EGL_PLATFORM_X) mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain"); +#endif + if (!mainFunc) { _eglLog(_EGL_WARNING, "_eglMain not found in %s", driverFilename); +#if defined(_EGL_PLATFORM_WINDOWS) + FreeLibrary(lib); +#elif defined(_EGL_PLATFORM_X) dlclose(lib); +#endif return NULL; } drv = mainFunc(dpy, args); if (!drv) { +#if defined(_EGL_PLATFORM_WINDOWS) + FreeLibrary(lib); +#elif defined(_EGL_PLATFORM_X) dlclose(lib); +#endif return NULL; } + /* with a recurvise open you want the inner most handle */ - if (!drv->LibHandle) + if (!drv->LibHandle) { drv->LibHandle = lib; - else + } + else { +#if defined(_EGL_PLATFORM_WINDOWS) + FreeLibrary(lib); +#elif defined(_EGL_PLATFORM_X) dlclose(lib); +#endif + } /* update the global notion of supported APIs */ _eglGlobal.ClientAPIsMask |= drv->ClientAPIsMask; @@ -221,7 +252,13 @@ _eglCloseDriver(_EGLDriver *drv, EGLDisplay dpy) */ b = drv->API.Terminate(drv, dpy); + +#if defined(_EGL_PLATFORM_WINDOWS) + FreeLibrary(handle); +#elif defined(_EGL_PLATFORM_X) dlclose(handle); +#endif + return b; }