From b7d0c6037d5a0860434fb068693eb0973012c31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 16 Jul 2021 14:57:22 +0200 Subject: [PATCH] Make dynamic module loading part of platform API This is part of the preparations for runtime platform selection. --- src/CMakeLists.txt | 8 +- src/cocoa_init.m | 2 +- src/cocoa_platform.h | 5 - src/egl_context.c | 44 +++--- src/glx_context.c | 66 ++++----- src/internal.h | 5 + src/null_platform.h | 12 -- src/osmesa_context.c | 18 +-- src/posix_module.c | 51 +++++++ src/vulkan.c | 14 +- src/wgl_context.c | 20 +-- src/win32_init.c | 62 ++++---- src/win32_module.c | 49 +++++++ src/win32_platform.h | 4 - src/wl_init.c | 100 ++++++------- src/wl_platform.h | 5 - src/x11_init.c | 336 +++++++++++++++++++++---------------------- src/x11_platform.h | 5 - 18 files changed, 443 insertions(+), 363 deletions(-) create mode 100644 src/posix_module.c create mode 100644 src/win32_module.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2b6e6243..850074c0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,6 +52,12 @@ elseif (_GLFW_OSMESA) osmesa_context.c) endif() +if (WIN32) + target_sources(glfw PRIVATE win32_module.c) +else() + target_sources(glfw PRIVATE posix_module.c) +endif() + if (_GLFW_X11 OR _GLFW_WAYLAND) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c) @@ -250,7 +256,7 @@ endif() if (CMAKE_C_COMPILER_ID STREQUAL "GNU") set_source_files_properties(context.c init.c input.c monitor.c vulkan.c window.c win32_init.c win32_joystick.c - win32_monitor.c win32_time.c win32_thread.c + win32_module.c win32_monitor.c win32_time.c win32_thread.c win32_window.c wgl_context.c egl_context.c osmesa_context.c PROPERTIES COMPILE_FLAGS -Wdeclaration-after-statement) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index a41667b0..701265a5 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -478,7 +478,7 @@ void* _glfwLoadLocalVulkanLoaderNS(void) void* handle = NULL; if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1)) - handle = _glfw_dlopen(path); + handle = _glfwPlatformLoadModule(path); CFRelease(url); return handle; diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 1ebf2c65..ba575ffa 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -25,7 +25,6 @@ //======================================================================== #include -#include #include @@ -88,10 +87,6 @@ typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMeta #include "cocoa_joystick.h" #include "nsgl_context.h" -#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) -#define _glfw_dlclose(handle) dlclose(handle) -#define _glfw_dlsym(handle, name) dlsym(handle, name) - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns diff --git a/src/egl_context.c b/src/egl_context.c index d25c5bd1..8d4df682 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -256,8 +256,8 @@ static GLFWglproc getProcAddressEGL(const char* procname) if (window->context.egl.client) { - GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->context.egl.client, - procname); + GLFWglproc proc = (GLFWglproc) + _glfwPlatformGetModuleSymbol(window->context.egl.client, procname); if (proc) return proc; } @@ -275,7 +275,7 @@ static void destroyContextEGL(_GLFWwindow* window) { if (window->context.egl.client) { - _glfw_dlclose(window->context.egl.client); + _glfwPlatformFreeModule(window->context.egl.client); window->context.egl.client = NULL; } } @@ -327,7 +327,7 @@ GLFWbool _glfwInitEGL(void) for (i = 0; sonames[i]; i++) { - _glfw.egl.handle = _glfw_dlopen(sonames[i]); + _glfw.egl.handle = _glfwPlatformLoadModule(sonames[i]); if (_glfw.egl.handle) break; } @@ -341,37 +341,37 @@ GLFWbool _glfwInitEGL(void) _glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0); _glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib) - _glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigAttrib"); _glfw.egl.GetConfigs = (PFN_eglGetConfigs) - _glfw_dlsym(_glfw.egl.handle, "eglGetConfigs"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetConfigs"); _glfw.egl.GetDisplay = (PFN_eglGetDisplay) - _glfw_dlsym(_glfw.egl.handle, "eglGetDisplay"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetDisplay"); _glfw.egl.GetError = (PFN_eglGetError) - _glfw_dlsym(_glfw.egl.handle, "eglGetError"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetError"); _glfw.egl.Initialize = (PFN_eglInitialize) - _glfw_dlsym(_glfw.egl.handle, "eglInitialize"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglInitialize"); _glfw.egl.Terminate = (PFN_eglTerminate) - _glfw_dlsym(_glfw.egl.handle, "eglTerminate"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglTerminate"); _glfw.egl.BindAPI = (PFN_eglBindAPI) - _glfw_dlsym(_glfw.egl.handle, "eglBindAPI"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglBindAPI"); _glfw.egl.CreateContext = (PFN_eglCreateContext) - _glfw_dlsym(_glfw.egl.handle, "eglCreateContext"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateContext"); _glfw.egl.DestroySurface = (PFN_eglDestroySurface) - _glfw_dlsym(_glfw.egl.handle, "eglDestroySurface"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroySurface"); _glfw.egl.DestroyContext = (PFN_eglDestroyContext) - _glfw_dlsym(_glfw.egl.handle, "eglDestroyContext"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroyContext"); _glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface) - _glfw_dlsym(_glfw.egl.handle, "eglCreateWindowSurface"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateWindowSurface"); _glfw.egl.MakeCurrent = (PFN_eglMakeCurrent) - _glfw_dlsym(_glfw.egl.handle, "eglMakeCurrent"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglMakeCurrent"); _glfw.egl.SwapBuffers = (PFN_eglSwapBuffers) - _glfw_dlsym(_glfw.egl.handle, "eglSwapBuffers"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapBuffers"); _glfw.egl.SwapInterval = (PFN_eglSwapInterval) - _glfw_dlsym(_glfw.egl.handle, "eglSwapInterval"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglSwapInterval"); _glfw.egl.QueryString = (PFN_eglQueryString) - _glfw_dlsym(_glfw.egl.handle, "eglQueryString"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglQueryString"); _glfw.egl.GetProcAddress = (PFN_eglGetProcAddress) - _glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress"); + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglGetProcAddress"); if (!_glfw.egl.GetConfigAttrib || !_glfw.egl.GetConfigs || @@ -488,7 +488,7 @@ void _glfwTerminateEGL(void) if (_glfw.egl.handle) { - _glfw_dlclose(_glfw.egl.handle); + _glfwPlatformFreeModule(_glfw.egl.handle); _glfw.egl.handle = NULL; } } @@ -737,7 +737,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0)) continue; - window->context.egl.client = _glfw_dlopen(sonames[i]); + window->context.egl.client = _glfwPlatformLoadModule(sonames[i]); if (window->context.egl.client) break; } diff --git a/src/glx_context.c b/src/glx_context.c index 1abc1797..02c1c5e4 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -226,7 +226,7 @@ static GLFWglproc getProcAddressGLX(const char* procname) else if (_glfw.glx.GetProcAddressARB) return _glfw.glx.GetProcAddressARB((const GLubyte*) procname); else - return _glfw_dlsym(_glfw.glx.handle, procname); + return _glfwPlatformGetModuleSymbol(_glfw.glx.handle, procname); } static void destroyContextGLX(_GLFWwindow* window) @@ -272,7 +272,7 @@ GLFWbool _glfwInitGLX(void) for (i = 0; sonames[i]; i++) { - _glfw.glx.handle = _glfw_dlopen(sonames[i]); + _glfw.glx.handle = _glfwPlatformLoadModule(sonames[i]); if (_glfw.glx.handle) break; } @@ -283,36 +283,36 @@ GLFWbool _glfwInitGLX(void) return GLFW_FALSE; } - _glfw.glx.GetFBConfigs = - _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigs"); - _glfw.glx.GetFBConfigAttrib = - _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib"); - _glfw.glx.GetClientString = - _glfw_dlsym(_glfw.glx.handle, "glXGetClientString"); - _glfw.glx.QueryExtension = - _glfw_dlsym(_glfw.glx.handle, "glXQueryExtension"); - _glfw.glx.QueryVersion = - _glfw_dlsym(_glfw.glx.handle, "glXQueryVersion"); - _glfw.glx.DestroyContext = - _glfw_dlsym(_glfw.glx.handle, "glXDestroyContext"); - _glfw.glx.MakeCurrent = - _glfw_dlsym(_glfw.glx.handle, "glXMakeCurrent"); - _glfw.glx.SwapBuffers = - _glfw_dlsym(_glfw.glx.handle, "glXSwapBuffers"); - _glfw.glx.QueryExtensionsString = - _glfw_dlsym(_glfw.glx.handle, "glXQueryExtensionsString"); - _glfw.glx.CreateNewContext = - _glfw_dlsym(_glfw.glx.handle, "glXCreateNewContext"); - _glfw.glx.CreateWindow = - _glfw_dlsym(_glfw.glx.handle, "glXCreateWindow"); - _glfw.glx.DestroyWindow = - _glfw_dlsym(_glfw.glx.handle, "glXDestroyWindow"); - _glfw.glx.GetProcAddress = - _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddress"); - _glfw.glx.GetProcAddressARB = - _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddressARB"); - _glfw.glx.GetVisualFromFBConfig = - _glfw_dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig"); + _glfw.glx.GetFBConfigs = (PFNGLXGETFBCONFIGSPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigs"); + _glfw.glx.GetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetFBConfigAttrib"); + _glfw.glx.GetClientString = (PFNGLXGETCLIENTSTRINGPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetClientString"); + _glfw.glx.QueryExtension = (PFNGLXQUERYEXTENSIONPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtension"); + _glfw.glx.QueryVersion = (PFNGLXQUERYVERSIONPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryVersion"); + _glfw.glx.DestroyContext = (PFNGLXDESTROYCONTEXTPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyContext"); + _glfw.glx.MakeCurrent = (PFNGLXMAKECURRENTPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXMakeCurrent"); + _glfw.glx.SwapBuffers = (PFNGLXSWAPBUFFERSPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXSwapBuffers"); + _glfw.glx.QueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXQueryExtensionsString"); + _glfw.glx.CreateNewContext = (PFNGLXCREATENEWCONTEXTPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateNewContext"); + _glfw.glx.CreateWindow = (PFNGLXCREATEWINDOWPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXCreateWindow"); + _glfw.glx.DestroyWindow = (PFNGLXDESTROYWINDOWPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXDestroyWindow"); + _glfw.glx.GetProcAddress = (PFNGLXGETPROCADDRESSPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddress"); + _glfw.glx.GetProcAddressARB = (PFNGLXGETPROCADDRESSPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetProcAddressARB"); + _glfw.glx.GetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC) + _glfwPlatformGetModuleSymbol(_glfw.glx.handle, "glXGetVisualFromFBConfig"); if (!_glfw.glx.GetFBConfigs || !_glfw.glx.GetFBConfigAttrib || @@ -429,7 +429,7 @@ void _glfwTerminateGLX(void) if (_glfw.glx.handle) { - _glfw_dlclose(_glfw.glx.handle); + _glfwPlatformFreeModule(_glfw.glx.handle); _glfw.glx.handle = NULL; } } diff --git a/src/internal.h b/src/internal.h index 47f779e0..3ffc8d4e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -59,6 +59,7 @@ #define _GLFW_MESSAGE_SIZE 1024 typedef int GLFWbool; +typedef void (*GLFWproc)(void); typedef struct _GLFWerror _GLFWerror; typedef struct _GLFWinitconfig _GLFWinitconfig; @@ -721,6 +722,10 @@ void _glfwPlatformDestroyMutex(_GLFWmutex* mutex); void _glfwPlatformLockMutex(_GLFWmutex* mutex); void _glfwPlatformUnlockMutex(_GLFWmutex* mutex); +void* _glfwPlatformLoadModule(const char* path); +void _glfwPlatformFreeModule(void* module); +GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name); + ////////////////////////////////////////////////////////////////////////// ////// GLFW event API ////// diff --git a/src/null_platform.h b/src/null_platform.h index 49436dcc..e0b3f2ce 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -25,8 +25,6 @@ // //======================================================================== -#include - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNull null @@ -39,16 +37,6 @@ #include "posix_thread.h" #include "null_joystick.h" -#if defined(_GLFW_WIN32) - #define _glfw_dlopen(name) LoadLibraryA(name) - #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) - #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) -#else - #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) - #define _glfw_dlclose(handle) dlclose(handle) - #define _glfw_dlsym(handle, name) dlsym(handle, name) -#endif - // Null-specific per-window data // typedef struct _GLFWwindowNull diff --git a/src/osmesa_context.c b/src/osmesa_context.c index da39ffcf..0bae30c9 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -136,7 +136,7 @@ GLFWbool _glfwInitOSMesa(void) for (i = 0; sonames[i]; i++) { - _glfw.osmesa.handle = _glfw_dlopen(sonames[i]); + _glfw.osmesa.handle = _glfwPlatformLoadModule(sonames[i]); if (_glfw.osmesa.handle) break; } @@ -148,19 +148,19 @@ GLFWbool _glfwInitOSMesa(void) } _glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextExt"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextExt"); _glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextAttribs"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaCreateContextAttribs"); _glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaDestroyContext"); _glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaMakeCurrent"); _glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetColorBuffer"); _glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetDepthBuffer"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetDepthBuffer"); _glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress) - _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress"); + _glfwPlatformGetModuleSymbol(_glfw.osmesa.handle, "OSMesaGetProcAddress"); if (!_glfw.osmesa.CreateContextExt || !_glfw.osmesa.DestroyContext || @@ -183,7 +183,7 @@ void _glfwTerminateOSMesa(void) { if (_glfw.osmesa.handle) { - _glfw_dlclose(_glfw.osmesa.handle); + _glfwPlatformFreeModule(_glfw.osmesa.handle); _glfw.osmesa.handle = NULL; } } diff --git a/src/posix_module.c b/src/posix_module.c new file mode 100644 index 00000000..7079e5b4 --- /dev/null +++ b/src/posix_module.c @@ -0,0 +1,51 @@ +//======================================================================== +// GLFW 3.4 POSIX - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2021 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== +// It is fine to use C99 in this file because it will not be built with VS +//======================================================================== + +#include "internal.h" + +#include + +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// + +void* _glfwPlatformLoadModule(const char* path) +{ + return dlopen(path, RTLD_LAZY | RTLD_LOCAL); +} + +void _glfwPlatformFreeModule(void* module) +{ + dlclose(module); +} + +GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name) +{ + return dlsym(module, name); +} + diff --git a/src/vulkan.c b/src/vulkan.c index e810ca06..ad299e5e 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -52,15 +52,15 @@ GLFWbool _glfwInitVulkan(int mode) #if !defined(_GLFW_VULKAN_STATIC) #if defined(_GLFW_VULKAN_LIBRARY) - _glfw.vk.handle = _glfw_dlopen(_GLFW_VULKAN_LIBRARY); + _glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY); #elif defined(_GLFW_WIN32) - _glfw.vk.handle = _glfw_dlopen("vulkan-1.dll"); + _glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll"); #elif defined(_GLFW_COCOA) - _glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib"); + _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); if (!_glfw.vk.handle) _glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS(); #else - _glfw.vk.handle = _glfw_dlopen("libvulkan.so.1"); + _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so.1"); #endif if (!_glfw.vk.handle) { @@ -71,7 +71,7 @@ GLFWbool _glfwInitVulkan(int mode) } _glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) - _glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr"); + _glfwPlatformGetModuleSymbol(_glfw.vk.handle, "vkGetInstanceProcAddr"); if (!_glfw.vk.GetInstanceProcAddr) { _glfwInputError(GLFW_API_UNAVAILABLE, @@ -158,7 +158,7 @@ void _glfwTerminateVulkan(void) { #if !defined(_GLFW_VULKAN_STATIC) if (_glfw.vk.handle) - _glfw_dlclose(_glfw.vk.handle); + _glfwPlatformFreeModule(_glfw.vk.handle); #endif } @@ -266,7 +266,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, } #else if (!proc) - proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname); + proc = (GLFWvkproc) _glfwPlatformGetModuleSymbol(_glfw.vk.handle, procname); #endif return proc; diff --git a/src/wgl_context.c b/src/wgl_context.c index 2c452661..a7b3ec7b 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -387,7 +387,7 @@ static GLFWglproc getProcAddressWGL(const char* procname) if (proc) return proc; - return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname); + return (GLFWglproc) _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, procname); } static void destroyContextWGL(_GLFWwindow* window) @@ -415,7 +415,7 @@ GLFWbool _glfwInitWGL(void) if (_glfw.wgl.instance) return GLFW_TRUE; - _glfw.wgl.instance = LoadLibraryA("opengl32.dll"); + _glfw.wgl.instance = _glfwPlatformLoadModule("opengl32.dll"); if (!_glfw.wgl.instance) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, @@ -424,19 +424,19 @@ GLFWbool _glfwInitWGL(void) } _glfw.wgl.CreateContext = (PFN_wglCreateContext) - GetProcAddress(_glfw.wgl.instance, "wglCreateContext"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglCreateContext"); _glfw.wgl.DeleteContext = (PFN_wglDeleteContext) - GetProcAddress(_glfw.wgl.instance, "wglDeleteContext"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglDeleteContext"); _glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress) - GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetProcAddress"); _glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC) - GetProcAddress(_glfw.wgl.instance, "wglGetCurrentDC"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentDC"); _glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext) - GetProcAddress(_glfw.wgl.instance, "wglGetCurrentContext"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglGetCurrentContext"); _glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent) - GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglMakeCurrent"); _glfw.wgl.ShareLists = (PFN_wglShareLists) - GetProcAddress(_glfw.wgl.instance, "wglShareLists"); + _glfwPlatformGetModuleSymbol(_glfw.wgl.instance, "wglShareLists"); // NOTE: A dummy context has to be created for opengl32.dll to load the // OpenGL ICD, from which we can then query WGL extensions @@ -529,7 +529,7 @@ GLFWbool _glfwInitWGL(void) void _glfwTerminateWGL(void) { if (_glfw.wgl.instance) - FreeLibrary(_glfw.wgl.instance); + _glfwPlatformFreeModule(_glfw.wgl.instance); } #define setAttrib(a, v) \ diff --git a/src/win32_init.c b/src/win32_init.c index b871806e..53acab54 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -71,7 +71,7 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) // static GLFWbool loadLibraries(void) { - _glfw.win32.winmm.instance = LoadLibraryA("winmm.dll"); + _glfw.win32.winmm.instance = _glfwPlatformLoadModule("winmm.dll"); if (!_glfw.win32.winmm.instance) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, @@ -80,9 +80,9 @@ static GLFWbool loadLibraries(void) } _glfw.win32.winmm.GetTime = (PFN_timeGetTime) - GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime"); + _glfwPlatformGetModuleSymbol(_glfw.win32.winmm.instance, "timeGetTime"); - _glfw.win32.user32.instance = LoadLibraryA("user32.dll"); + _glfw.win32.user32.instance = _glfwPlatformLoadModule("user32.dll"); if (!_glfw.win32.user32.instance) { _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, @@ -91,23 +91,23 @@ static GLFWbool loadLibraries(void) } _glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware) - GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware"); _glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx) - GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx"); _glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling) - GetProcAddress(_glfw.win32.user32.instance, "EnableNonClientDpiScaling"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling"); _glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext) - GetProcAddress(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext"); _glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow) - GetProcAddress(_glfw.win32.user32.instance, "GetDpiForWindow"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "GetDpiForWindow"); _glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi) - GetProcAddress(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi"); + _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi"); - _glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll"); + _glfw.win32.dinput8.instance = _glfwPlatformLoadModule("dinput8.dll"); if (_glfw.win32.dinput8.instance) { _glfw.win32.dinput8.Create = (PFN_DirectInput8Create) - GetProcAddress(_glfw.win32.dinput8.instance, "DirectInput8Create"); + _glfwPlatformGetModuleSymbol(_glfw.win32.dinput8.instance, "DirectInput8Create"); } { @@ -124,46 +124,46 @@ static GLFWbool loadLibraries(void) for (i = 0; names[i]; i++) { - _glfw.win32.xinput.instance = LoadLibraryA(names[i]); + _glfw.win32.xinput.instance = _glfwPlatformLoadModule(names[i]); if (_glfw.win32.xinput.instance) { _glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities) - GetProcAddress(_glfw.win32.xinput.instance, "XInputGetCapabilities"); + _glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetCapabilities"); _glfw.win32.xinput.GetState = (PFN_XInputGetState) - GetProcAddress(_glfw.win32.xinput.instance, "XInputGetState"); + _glfwPlatformGetModuleSymbol(_glfw.win32.xinput.instance, "XInputGetState"); break; } } } - _glfw.win32.dwmapi.instance = LoadLibraryA("dwmapi.dll"); + _glfw.win32.dwmapi.instance = _glfwPlatformLoadModule("dwmapi.dll"); if (_glfw.win32.dwmapi.instance) { _glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled) - GetProcAddress(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled"); + _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled"); _glfw.win32.dwmapi.Flush = (PFN_DwmFlush) - GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush"); + _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmFlush"); _glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow) - GetProcAddress(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow"); + _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow"); _glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor) - GetProcAddress(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor"); + _glfwPlatformGetModuleSymbol(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor"); } - _glfw.win32.shcore.instance = LoadLibraryA("shcore.dll"); + _glfw.win32.shcore.instance = _glfwPlatformLoadModule("shcore.dll"); if (_glfw.win32.shcore.instance) { _glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness) - GetProcAddress(_glfw.win32.shcore.instance, "SetProcessDpiAwareness"); + _glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "SetProcessDpiAwareness"); _glfw.win32.shcore.GetDpiForMonitor_ = (PFN_GetDpiForMonitor) - GetProcAddress(_glfw.win32.shcore.instance, "GetDpiForMonitor"); + _glfwPlatformGetModuleSymbol(_glfw.win32.shcore.instance, "GetDpiForMonitor"); } - _glfw.win32.ntdll.instance = LoadLibraryA("ntdll.dll"); + _glfw.win32.ntdll.instance = _glfwPlatformLoadModule("ntdll.dll"); if (_glfw.win32.ntdll.instance) { _glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo) - GetProcAddress(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo"); + _glfwPlatformGetModuleSymbol(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo"); } return GLFW_TRUE; @@ -174,25 +174,25 @@ static GLFWbool loadLibraries(void) static void freeLibraries(void) { if (_glfw.win32.xinput.instance) - FreeLibrary(_glfw.win32.xinput.instance); + _glfwPlatformFreeModule(_glfw.win32.xinput.instance); if (_glfw.win32.dinput8.instance) - FreeLibrary(_glfw.win32.dinput8.instance); + _glfwPlatformFreeModule(_glfw.win32.dinput8.instance); if (_glfw.win32.winmm.instance) - FreeLibrary(_glfw.win32.winmm.instance); + _glfwPlatformFreeModule(_glfw.win32.winmm.instance); if (_glfw.win32.user32.instance) - FreeLibrary(_glfw.win32.user32.instance); + _glfwPlatformFreeModule(_glfw.win32.user32.instance); if (_glfw.win32.dwmapi.instance) - FreeLibrary(_glfw.win32.dwmapi.instance); + _glfwPlatformFreeModule(_glfw.win32.dwmapi.instance); if (_glfw.win32.shcore.instance) - FreeLibrary(_glfw.win32.shcore.instance); + _glfwPlatformFreeModule(_glfw.win32.shcore.instance); if (_glfw.win32.ntdll.instance) - FreeLibrary(_glfw.win32.ntdll.instance); + _glfwPlatformFreeModule(_glfw.win32.ntdll.instance); } // Create key code translation tables diff --git a/src/win32_module.c b/src/win32_module.c new file mode 100644 index 00000000..35bdd71d --- /dev/null +++ b/src/win32_module.c @@ -0,0 +1,49 @@ +//======================================================================== +// GLFW 3.4 Win32 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2021 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== +// Please use C89 style variable declarations in this file because VS 2010 +//======================================================================== + +#include "internal.h" + +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// + +void* _glfwPlatformLoadModule(const char* path) +{ + return LoadLibraryA(path); +} + +void _glfwPlatformFreeModule(void* module) +{ + FreeLibrary((HMODULE) module); +} + +GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name) +{ + return (GLFWproc) GetProcAddress((HMODULE) module, name); +} + diff --git a/src/win32_platform.h b/src/win32_platform.h index 715026eb..9008f131 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -284,10 +284,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)( #define _GLFW_WNDCLASSNAME L"GLFW30" #endif -#define _glfw_dlopen(name) LoadLibraryA(name) -#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) -#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32 #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32 diff --git a/src/wl_init.c b/src/wl_init.c index 5893970a..609283f6 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1053,7 +1053,7 @@ int _glfwPlatformInit(void) long cursorSizeLong; int cursorSize; - _glfw.wl.client.handle = _glfw_dlopen("libwayland-client.so.0"); + _glfw.wl.client.handle = _glfwPlatformLoadModule("libwayland-client.so.0"); if (!_glfw.wl.client.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1062,41 +1062,41 @@ int _glfwPlatformInit(void) } _glfw.wl.client.display_flush = (PFN_wl_display_flush) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_flush"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_flush"); _glfw.wl.client.display_cancel_read = (PFN_wl_display_cancel_read) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_cancel_read"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_cancel_read"); _glfw.wl.client.display_dispatch_pending = (PFN_wl_display_dispatch_pending) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_dispatch_pending"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_dispatch_pending"); _glfw.wl.client.display_read_events = (PFN_wl_display_read_events) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_read_events"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_read_events"); _glfw.wl.client.display_connect = (PFN_wl_display_connect) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_connect"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_connect"); _glfw.wl.client.display_disconnect = (PFN_wl_display_disconnect) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_disconnect"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_disconnect"); _glfw.wl.client.display_roundtrip = (PFN_wl_display_roundtrip) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_roundtrip"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_roundtrip"); _glfw.wl.client.display_get_fd = (PFN_wl_display_get_fd) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_get_fd"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_get_fd"); _glfw.wl.client.display_prepare_read = (PFN_wl_display_prepare_read) - _glfw_dlsym(_glfw.wl.client.handle, "wl_display_prepare_read"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_prepare_read"); _glfw.wl.client.proxy_marshal = (PFN_wl_proxy_marshal) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal"); _glfw.wl.client.proxy_add_listener = (PFN_wl_proxy_add_listener) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_add_listener"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_add_listener"); _glfw.wl.client.proxy_destroy = (PFN_wl_proxy_destroy) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_destroy"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_destroy"); _glfw.wl.client.proxy_marshal_constructor = (PFN_wl_proxy_marshal_constructor) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_constructor"); _glfw.wl.client.proxy_marshal_constructor_versioned = (PFN_wl_proxy_marshal_constructor_versioned) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_constructor_versioned"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_constructor_versioned"); _glfw.wl.client.proxy_get_user_data = (PFN_wl_proxy_get_user_data) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_user_data"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_user_data"); _glfw.wl.client.proxy_set_user_data = (PFN_wl_proxy_set_user_data) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_set_user_data"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_set_user_data"); _glfw.wl.client.proxy_get_version = (PFN_wl_proxy_get_version) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_get_version"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_version"); _glfw.wl.client.proxy_marshal_flags = (PFN_wl_proxy_marshal_flags) - _glfw_dlsym(_glfw.wl.client.handle, "wl_proxy_marshal_flags"); + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_flags"); if (!_glfw.wl.client.display_flush || !_glfw.wl.client.display_cancel_read || @@ -1120,7 +1120,7 @@ int _glfwPlatformInit(void) return GLFW_FALSE; } - _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0"); + _glfw.wl.cursor.handle = _glfwPlatformLoadModule("libwayland-cursor.so.0"); if (!_glfw.wl.cursor.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1129,15 +1129,15 @@ int _glfwPlatformInit(void) } _glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_load"); + _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_load"); _glfw.wl.cursor.theme_destroy = (PFN_wl_cursor_theme_destroy) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy"); + _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy"); _glfw.wl.cursor.theme_get_cursor = (PFN_wl_cursor_theme_get_cursor) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor"); + _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor"); _glfw.wl.cursor.image_get_buffer = (PFN_wl_cursor_image_get_buffer) - _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer"); + _glfwPlatformGetModuleSymbol(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer"); - _glfw.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1"); + _glfw.wl.egl.handle = _glfwPlatformLoadModule("libwayland-egl.so.1"); if (!_glfw.wl.egl.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1146,13 +1146,13 @@ int _glfwPlatformInit(void) } _glfw.wl.egl.window_create = (PFN_wl_egl_window_create) - _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_create"); + _glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_create"); _glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy) - _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_destroy"); + _glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_destroy"); _glfw.wl.egl.window_resize = (PFN_wl_egl_window_resize) - _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_resize"); + _glfwPlatformGetModuleSymbol(_glfw.wl.egl.handle, "wl_egl_window_resize"); - _glfw.wl.xkb.handle = _glfw_dlopen("libxkbcommon.so.0"); + _glfw.wl.xkb.handle = _glfwPlatformLoadModule("libxkbcommon.so.0"); if (!_glfw.wl.xkb.handle) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -1161,43 +1161,43 @@ int _glfwPlatformInit(void) } _glfw.wl.xkb.context_new = (PFN_xkb_context_new) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_new"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_new"); _glfw.wl.xkb.context_unref = (PFN_xkb_context_unref) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_unref"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_context_unref"); _glfw.wl.xkb.keymap_new_from_string = (PFN_xkb_keymap_new_from_string) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string"); _glfw.wl.xkb.keymap_unref = (PFN_xkb_keymap_unref) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_unref"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_unref"); _glfw.wl.xkb.keymap_mod_get_index = (PFN_xkb_keymap_mod_get_index) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index"); _glfw.wl.xkb.keymap_key_repeats = (PFN_xkb_keymap_key_repeats) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats"); _glfw.wl.xkb.state_new = (PFN_xkb_state_new) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_new"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_new"); _glfw.wl.xkb.state_unref = (PFN_xkb_state_unref) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_unref"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_unref"); _glfw.wl.xkb.state_key_get_syms = (PFN_xkb_state_key_get_syms) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_syms"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_key_get_syms"); _glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_update_mask"); _glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_state_serialize_mods"); #ifdef HAVE_XKBCOMMON_COMPOSE_H _glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale"); _glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_unref"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_table_unref"); _glfw.wl.xkb.compose_state_new = (PFN_xkb_compose_state_new) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_new"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_new"); _glfw.wl.xkb.compose_state_unref = (PFN_xkb_compose_state_unref) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_unref"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_unref"); _glfw.wl.xkb.compose_state_feed = (PFN_xkb_compose_state_feed) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_feed"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_feed"); _glfw.wl.xkb.compose_state_get_status = (PFN_xkb_compose_state_get_status) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_status"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_status"); _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym) - _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym"); + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym"); #endif _glfw.wl.display = wl_display_connect(NULL); @@ -1290,7 +1290,7 @@ void _glfwPlatformTerminate(void) _glfwTerminateEGL(); if (_glfw.wl.egl.handle) { - _glfw_dlclose(_glfw.wl.egl.handle); + _glfwPlatformFreeModule(_glfw.wl.egl.handle); _glfw.wl.egl.handle = NULL; } @@ -1306,7 +1306,7 @@ void _glfwPlatformTerminate(void) xkb_context_unref(_glfw.wl.xkb.context); if (_glfw.wl.xkb.handle) { - _glfw_dlclose(_glfw.wl.xkb.handle); + _glfwPlatformFreeModule(_glfw.wl.xkb.handle); _glfw.wl.xkb.handle = NULL; } @@ -1316,7 +1316,7 @@ void _glfwPlatformTerminate(void) wl_cursor_theme_destroy(_glfw.wl.cursorThemeHiDPI); if (_glfw.wl.cursor.handle) { - _glfw_dlclose(_glfw.wl.cursor.handle); + _glfwPlatformFreeModule(_glfw.wl.cursor.handle); _glfw.wl.cursor.handle = NULL; } diff --git a/src/wl_platform.h b/src/wl_platform.h index 777ae2e7..71512b59 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -29,7 +29,6 @@ #ifdef HAVE_XKBCOMMON_COMPOSE_H #include #endif -#include typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; @@ -133,10 +132,6 @@ struct wl_shm; #define xdg_toplevel_interface _glfw_xdg_toplevel_interface #define xdg_wm_base_interface _glfw_xdg_wm_base_interface -#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) -#define _glfw_dlclose(handle) dlclose(handle) -#define _glfw_dlsym(handle, name) dlsym(handle, name) - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl diff --git a/src/x11_init.c b/src/x11_init.c index e4cb09de..34e52252 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -601,17 +601,17 @@ static void detectEWMH(void) // static GLFWbool initExtensions(void) { - _glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1"); + _glfw.x11.vidmode.handle = _glfwPlatformLoadModule("libXxf86vm.so.1"); if (_glfw.x11.vidmode.handle) { _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension"); _glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp"); + _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp"); _glfw.x11.vidmode.SetGammaRamp = (PFN_XF86VidModeSetGammaRamp) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp"); + _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp"); _glfw.x11.vidmode.GetGammaRampSize = (PFN_XF86VidModeGetGammaRampSize) - _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize"); + _glfwPlatformGetModuleSymbol(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize"); _glfw.x11.vidmode.available = XF86VidModeQueryExtension(_glfw.x11.display, @@ -620,16 +620,16 @@ static GLFWbool initExtensions(void) } #if defined(__CYGWIN__) - _glfw.x11.xi.handle = _glfw_dlopen("libXi-6.so"); + _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi-6.so"); #else - _glfw.x11.xi.handle = _glfw_dlopen("libXi.so.6"); + _glfw.x11.xi.handle = _glfwPlatformLoadModule("libXi.so.6"); #endif if (_glfw.x11.xi.handle) { _glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion) - _glfw_dlsym(_glfw.x11.xi.handle, "XIQueryVersion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xi.handle, "XIQueryVersion"); _glfw.x11.xi.SelectEvents = (PFN_XISelectEvents) - _glfw_dlsym(_glfw.x11.xi.handle, "XISelectEvents"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xi.handle, "XISelectEvents"); if (XQueryExtension(_glfw.x11.display, "XInputExtension", @@ -650,48 +650,48 @@ static GLFWbool initExtensions(void) } #if defined(__CYGWIN__) - _glfw.x11.randr.handle = _glfw_dlopen("libXrandr-2.so"); + _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr-2.so"); #else - _glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so.2"); + _glfw.x11.randr.handle = _glfwPlatformLoadModule("libXrandr.so.2"); #endif if (_glfw.x11.randr.handle) { _glfw.x11.randr.AllocGamma = (PFN_XRRAllocGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRAllocGamma"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRAllocGamma"); _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeGamma"); _glfw.x11.randr.FreeCrtcInfo = (PFN_XRRFreeCrtcInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeCrtcInfo"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeCrtcInfo"); _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeGamma"); _glfw.x11.randr.FreeOutputInfo = (PFN_XRRFreeOutputInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeOutputInfo"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeOutputInfo"); _glfw.x11.randr.FreeScreenResources = (PFN_XRRFreeScreenResources) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeScreenResources"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRFreeScreenResources"); _glfw.x11.randr.GetCrtcGamma = (PFN_XRRGetCrtcGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGamma"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcGamma"); _glfw.x11.randr.GetCrtcGammaSize = (PFN_XRRGetCrtcGammaSize) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize"); _glfw.x11.randr.GetCrtcInfo = (PFN_XRRGetCrtcInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcInfo"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetCrtcInfo"); _glfw.x11.randr.GetOutputInfo = (PFN_XRRGetOutputInfo) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputInfo"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetOutputInfo"); _glfw.x11.randr.GetOutputPrimary = (PFN_XRRGetOutputPrimary) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputPrimary"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetOutputPrimary"); _glfw.x11.randr.GetScreenResourcesCurrent = (PFN_XRRGetScreenResourcesCurrent) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent"); _glfw.x11.randr.QueryExtension = (PFN_XRRQueryExtension) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRQueryExtension"); _glfw.x11.randr.QueryVersion = (PFN_XRRQueryVersion) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryVersion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRQueryVersion"); _glfw.x11.randr.SelectInput = (PFN_XRRSelectInput) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRSelectInput"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSelectInput"); _glfw.x11.randr.SetCrtcConfig = (PFN_XRRSetCrtcConfig) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcConfig"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSetCrtcConfig"); _glfw.x11.randr.SetCrtcGamma = (PFN_XRRSetCrtcGamma) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcGamma"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRSetCrtcGamma"); _glfw.x11.randr.UpdateConfiguration = (PFN_XRRUpdateConfiguration) - _glfw_dlsym(_glfw.x11.randr.handle, "XRRUpdateConfiguration"); + _glfwPlatformGetModuleSymbol(_glfw.x11.randr.handle, "XRRUpdateConfiguration"); if (XRRQueryExtension(_glfw.x11.display, &_glfw.x11.randr.eventBase, @@ -742,39 +742,39 @@ static GLFWbool initExtensions(void) } #if defined(__CYGWIN__) - _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor-1.so"); + _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor-1.so"); #else - _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so.1"); + _glfw.x11.xcursor.handle = _glfwPlatformLoadModule("libXcursor.so.1"); #endif if (_glfw.x11.xcursor.handle) { _glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageCreate"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageCreate"); _glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageDestroy"); _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor"); _glfw.x11.xcursor.GetTheme = (PFN_XcursorGetTheme) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetTheme"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorGetTheme"); _glfw.x11.xcursor.GetDefaultSize = (PFN_XcursorGetDefaultSize) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize"); _glfw.x11.xcursor.LibraryLoadImage = (PFN_XcursorLibraryLoadImage) - _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage"); } #if defined(__CYGWIN__) - _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama-1.so"); + _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama-1.so"); #else - _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so.1"); + _glfw.x11.xinerama.handle = _glfwPlatformLoadModule("libXinerama.so.1"); #endif if (_glfw.x11.xinerama.handle) { _glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive) - _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaIsActive"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaIsActive"); _glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension) - _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaQueryExtension"); _glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens) - _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryScreens"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xinerama.handle, "XineramaQueryScreens"); if (XineramaQueryExtension(_glfw.x11.display, &_glfw.x11.xinerama.major, @@ -816,31 +816,31 @@ static GLFWbool initExtensions(void) if (_glfw.hints.init.x11.xcbVulkanSurface) { #if defined(__CYGWIN__) - _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so"); + _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb-1.so"); #else - _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1"); + _glfw.x11.x11xcb.handle = _glfwPlatformLoadModule("libX11-xcb.so.1"); #endif } if (_glfw.x11.x11xcb.handle) { _glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection) - _glfw_dlsym(_glfw.x11.x11xcb.handle, "XGetXCBConnection"); + _glfwPlatformGetModuleSymbol(_glfw.x11.x11xcb.handle, "XGetXCBConnection"); } #if defined(__CYGWIN__) - _glfw.x11.xrender.handle = _glfw_dlopen("libXrender-1.so"); + _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender-1.so"); #else - _glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so.1"); + _glfw.x11.xrender.handle = _glfwPlatformLoadModule("libXrender.so.1"); #endif if (_glfw.x11.xrender.handle) { _glfw.x11.xrender.QueryExtension = (PFN_XRenderQueryExtension) - _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderQueryExtension"); _glfw.x11.xrender.QueryVersion = (PFN_XRenderQueryVersion) - _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryVersion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderQueryVersion"); _glfw.x11.xrender.FindVisualFormat = (PFN_XRenderFindVisualFormat) - _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderFindVisualFormat"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xrender.handle, "XRenderFindVisualFormat"); if (XRenderQueryExtension(_glfw.x11.display, &_glfw.x11.xrender.errorBase, @@ -856,20 +856,20 @@ static GLFWbool initExtensions(void) } #if defined(__CYGWIN__) - _glfw.x11.xshape.handle = _glfw_dlopen("libXext-6.so"); + _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext-6.so"); #else - _glfw.x11.xshape.handle = _glfw_dlopen("libXext.so.6"); + _glfw.x11.xshape.handle = _glfwPlatformLoadModule("libXext.so.6"); #endif if (_glfw.x11.xshape.handle) { _glfw.x11.xshape.QueryExtension = (PFN_XShapeQueryExtension) - _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeQueryExtension"); _glfw.x11.xshape.ShapeCombineRegion = (PFN_XShapeCombineRegion) - _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineRegion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeCombineRegion"); _glfw.x11.xshape.QueryVersion = (PFN_XShapeQueryVersion) - _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryVersion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeQueryVersion"); _glfw.x11.xshape.ShapeCombineMask = (PFN_XShapeCombineMask) - _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineMask"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xshape.handle, "XShapeCombineMask"); if (XShapeQueryExtension(_glfw.x11.display, &_glfw.x11.xshape.errorBase, @@ -1119,9 +1119,9 @@ int _glfwPlatformInit(void) setlocale(LC_CTYPE, ""); #if defined(__CYGWIN__) - _glfw.x11.xlib.handle = _glfw_dlopen("libX11-6.so"); + _glfw.x11.xlib.handle = _glfwPlatformLoadModule("libX11-6.so"); #else - _glfw.x11.xlib.handle = _glfw_dlopen("libX11.so.6"); + _glfw.x11.xlib.handle = _glfwPlatformLoadModule("libX11.so.6"); #endif if (!_glfw.x11.xlib.handle) { @@ -1130,209 +1130,209 @@ int _glfwPlatformInit(void) } _glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint) - _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocClassHint"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocClassHint"); _glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints) - _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocSizeHints"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocSizeHints"); _glfw.x11.xlib.AllocWMHints = (PFN_XAllocWMHints) - _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocWMHints"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XAllocWMHints"); _glfw.x11.xlib.ChangeProperty = (PFN_XChangeProperty) - _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeProperty"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XChangeProperty"); _glfw.x11.xlib.ChangeWindowAttributes = (PFN_XChangeWindowAttributes) - _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeWindowAttributes"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XChangeWindowAttributes"); _glfw.x11.xlib.CheckIfEvent = (PFN_XCheckIfEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckIfEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCheckIfEvent"); _glfw.x11.xlib.CheckTypedWindowEvent = (PFN_XCheckTypedWindowEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckTypedWindowEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCheckTypedWindowEvent"); _glfw.x11.xlib.CloseDisplay = (PFN_XCloseDisplay) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseDisplay"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCloseDisplay"); _glfw.x11.xlib.CloseIM = (PFN_XCloseIM) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseIM"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCloseIM"); _glfw.x11.xlib.ConvertSelection = (PFN_XConvertSelection) - _glfw_dlsym(_glfw.x11.xlib.handle, "XConvertSelection"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XConvertSelection"); _glfw.x11.xlib.CreateColormap = (PFN_XCreateColormap) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateColormap"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateColormap"); _glfw.x11.xlib.CreateFontCursor = (PFN_XCreateFontCursor) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateFontCursor"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateFontCursor"); _glfw.x11.xlib.CreateIC = (PFN_XCreateIC) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateIC"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateIC"); _glfw.x11.xlib.CreateRegion = (PFN_XCreateRegion) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateRegion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateRegion"); _glfw.x11.xlib.CreateWindow = (PFN_XCreateWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XCreateWindow"); _glfw.x11.xlib.DefineCursor = (PFN_XDefineCursor) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDefineCursor"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDefineCursor"); _glfw.x11.xlib.DeleteContext = (PFN_XDeleteContext) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteContext"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDeleteContext"); _glfw.x11.xlib.DeleteProperty = (PFN_XDeleteProperty) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteProperty"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDeleteProperty"); _glfw.x11.xlib.DestroyIC = (PFN_XDestroyIC) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyIC"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyIC"); _glfw.x11.xlib.DestroyRegion = (PFN_XDestroyRegion) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyRegion"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyRegion"); _glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDestroyWindow"); _glfw.x11.xlib.DisplayKeycodes = (PFN_XDisplayKeycodes) - _glfw_dlsym(_glfw.x11.xlib.handle, "XDisplayKeycodes"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XDisplayKeycodes"); _glfw.x11.xlib.EventsQueued = (PFN_XEventsQueued) - _glfw_dlsym(_glfw.x11.xlib.handle, "XEventsQueued"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XEventsQueued"); _glfw.x11.xlib.FilterEvent = (PFN_XFilterEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFilterEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFilterEvent"); _glfw.x11.xlib.FindContext = (PFN_XFindContext) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFindContext"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFindContext"); _glfw.x11.xlib.Flush = (PFN_XFlush) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFlush"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFlush"); _glfw.x11.xlib.Free = (PFN_XFree) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFree"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFree"); _glfw.x11.xlib.FreeColormap = (PFN_XFreeColormap) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeColormap"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeColormap"); _glfw.x11.xlib.FreeCursor = (PFN_XFreeCursor) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeCursor"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeCursor"); _glfw.x11.xlib.FreeEventData = (PFN_XFreeEventData) - _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeEventData"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XFreeEventData"); _glfw.x11.xlib.GetErrorText = (PFN_XGetErrorText) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetErrorText"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetErrorText"); _glfw.x11.xlib.GetEventData = (PFN_XGetEventData) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetEventData"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetEventData"); _glfw.x11.xlib.GetICValues = (PFN_XGetICValues) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetICValues"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetICValues"); _glfw.x11.xlib.GetIMValues = (PFN_XGetIMValues) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetIMValues"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetIMValues"); _glfw.x11.xlib.GetInputFocus = (PFN_XGetInputFocus) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetInputFocus"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetInputFocus"); _glfw.x11.xlib.GetKeyboardMapping = (PFN_XGetKeyboardMapping) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetKeyboardMapping"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetKeyboardMapping"); _glfw.x11.xlib.GetScreenSaver = (PFN_XGetScreenSaver) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetScreenSaver"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetScreenSaver"); _glfw.x11.xlib.GetSelectionOwner = (PFN_XGetSelectionOwner) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetSelectionOwner"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetSelectionOwner"); _glfw.x11.xlib.GetVisualInfo = (PFN_XGetVisualInfo) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetVisualInfo"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetVisualInfo"); _glfw.x11.xlib.GetWMNormalHints = (PFN_XGetWMNormalHints) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWMNormalHints"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWMNormalHints"); _glfw.x11.xlib.GetWindowAttributes = (PFN_XGetWindowAttributes) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowAttributes"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWindowAttributes"); _glfw.x11.xlib.GetWindowProperty = (PFN_XGetWindowProperty) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowProperty"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGetWindowProperty"); _glfw.x11.xlib.GrabPointer = (PFN_XGrabPointer) - _glfw_dlsym(_glfw.x11.xlib.handle, "XGrabPointer"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XGrabPointer"); _glfw.x11.xlib.IconifyWindow = (PFN_XIconifyWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XIconifyWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XIconifyWindow"); _glfw.x11.xlib.InitThreads = (PFN_XInitThreads) - _glfw_dlsym(_glfw.x11.xlib.handle, "XInitThreads"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XInitThreads"); _glfw.x11.xlib.InternAtom = (PFN_XInternAtom) - _glfw_dlsym(_glfw.x11.xlib.handle, "XInternAtom"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XInternAtom"); _glfw.x11.xlib.LookupString = (PFN_XLookupString) - _glfw_dlsym(_glfw.x11.xlib.handle, "XLookupString"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XLookupString"); _glfw.x11.xlib.MapRaised = (PFN_XMapRaised) - _glfw_dlsym(_glfw.x11.xlib.handle, "XMapRaised"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMapRaised"); _glfw.x11.xlib.MapWindow = (PFN_XMapWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XMapWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMapWindow"); _glfw.x11.xlib.MoveResizeWindow = (PFN_XMoveResizeWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveResizeWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMoveResizeWindow"); _glfw.x11.xlib.MoveWindow = (PFN_XMoveWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XMoveWindow"); _glfw.x11.xlib.NextEvent = (PFN_XNextEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XNextEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XNextEvent"); _glfw.x11.xlib.OpenDisplay = (PFN_XOpenDisplay) - _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenDisplay"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XOpenDisplay"); _glfw.x11.xlib.OpenIM = (PFN_XOpenIM) - _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenIM"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XOpenIM"); _glfw.x11.xlib.PeekEvent = (PFN_XPeekEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XPeekEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XPeekEvent"); _glfw.x11.xlib.Pending = (PFN_XPending) - _glfw_dlsym(_glfw.x11.xlib.handle, "XPending"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XPending"); _glfw.x11.xlib.QueryExtension = (PFN_XQueryExtension) - _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XQueryExtension"); _glfw.x11.xlib.QueryPointer = (PFN_XQueryPointer) - _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryPointer"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XQueryPointer"); _glfw.x11.xlib.RaiseWindow = (PFN_XRaiseWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XRaiseWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XRaiseWindow"); _glfw.x11.xlib.RegisterIMInstantiateCallback = (PFN_XRegisterIMInstantiateCallback) - _glfw_dlsym(_glfw.x11.xlib.handle, "XRegisterIMInstantiateCallback"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XRegisterIMInstantiateCallback"); _glfw.x11.xlib.ResizeWindow = (PFN_XResizeWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XResizeWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XResizeWindow"); _glfw.x11.xlib.ResourceManagerString = (PFN_XResourceManagerString) - _glfw_dlsym(_glfw.x11.xlib.handle, "XResourceManagerString"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XResourceManagerString"); _glfw.x11.xlib.SaveContext = (PFN_XSaveContext) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSaveContext"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSaveContext"); _glfw.x11.xlib.SelectInput = (PFN_XSelectInput) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSelectInput"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSelectInput"); _glfw.x11.xlib.SendEvent = (PFN_XSendEvent) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSendEvent"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSendEvent"); _glfw.x11.xlib.SetClassHint = (PFN_XSetClassHint) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetClassHint"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetClassHint"); _glfw.x11.xlib.SetErrorHandler = (PFN_XSetErrorHandler) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetErrorHandler"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetErrorHandler"); _glfw.x11.xlib.SetICFocus = (PFN_XSetICFocus) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetICFocus"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetICFocus"); _glfw.x11.xlib.SetIMValues = (PFN_XSetIMValues) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetIMValues"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetIMValues"); _glfw.x11.xlib.SetInputFocus = (PFN_XSetInputFocus) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetInputFocus"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetInputFocus"); _glfw.x11.xlib.SetLocaleModifiers = (PFN_XSetLocaleModifiers) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetLocaleModifiers"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetLocaleModifiers"); _glfw.x11.xlib.SetScreenSaver = (PFN_XSetScreenSaver) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetScreenSaver"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetScreenSaver"); _glfw.x11.xlib.SetSelectionOwner = (PFN_XSetSelectionOwner) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetSelectionOwner"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetSelectionOwner"); _glfw.x11.xlib.SetWMHints = (PFN_XSetWMHints) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMHints"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMHints"); _glfw.x11.xlib.SetWMNormalHints = (PFN_XSetWMNormalHints) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMNormalHints"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMNormalHints"); _glfw.x11.xlib.SetWMProtocols = (PFN_XSetWMProtocols) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMProtocols"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSetWMProtocols"); _glfw.x11.xlib.SupportsLocale = (PFN_XSupportsLocale) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSupportsLocale"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSupportsLocale"); _glfw.x11.xlib.Sync = (PFN_XSync) - _glfw_dlsym(_glfw.x11.xlib.handle, "XSync"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XSync"); _glfw.x11.xlib.TranslateCoordinates = (PFN_XTranslateCoordinates) - _glfw_dlsym(_glfw.x11.xlib.handle, "XTranslateCoordinates"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XTranslateCoordinates"); _glfw.x11.xlib.UndefineCursor = (PFN_XUndefineCursor) - _glfw_dlsym(_glfw.x11.xlib.handle, "XUndefineCursor"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUndefineCursor"); _glfw.x11.xlib.UngrabPointer = (PFN_XUngrabPointer) - _glfw_dlsym(_glfw.x11.xlib.handle, "XUngrabPointer"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUngrabPointer"); _glfw.x11.xlib.UnmapWindow = (PFN_XUnmapWindow) - _glfw_dlsym(_glfw.x11.xlib.handle, "XUnmapWindow"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnmapWindow"); _glfw.x11.xlib.UnsetICFocus = (PFN_XUnsetICFocus) - _glfw_dlsym(_glfw.x11.xlib.handle, "XUnsetICFocus"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnsetICFocus"); _glfw.x11.xlib.VisualIDFromVisual = (PFN_XVisualIDFromVisual) - _glfw_dlsym(_glfw.x11.xlib.handle, "XVisualIDFromVisual"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XVisualIDFromVisual"); _glfw.x11.xlib.WarpPointer = (PFN_XWarpPointer) - _glfw_dlsym(_glfw.x11.xlib.handle, "XWarpPointer"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XWarpPointer"); _glfw.x11.xkb.FreeKeyboard = (PFN_XkbFreeKeyboard) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeKeyboard"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbFreeKeyboard"); _glfw.x11.xkb.FreeNames = (PFN_XkbFreeNames) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeNames"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbFreeNames"); _glfw.x11.xkb.GetMap = (PFN_XkbGetMap) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetMap"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetMap"); _glfw.x11.xkb.GetNames = (PFN_XkbGetNames) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetNames"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetNames"); _glfw.x11.xkb.GetState = (PFN_XkbGetState) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetState"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbGetState"); _glfw.x11.xkb.KeycodeToKeysym = (PFN_XkbKeycodeToKeysym) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbKeycodeToKeysym"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbKeycodeToKeysym"); _glfw.x11.xkb.QueryExtension = (PFN_XkbQueryExtension) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbQueryExtension"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbQueryExtension"); _glfw.x11.xkb.SelectEventDetails = (PFN_XkbSelectEventDetails) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSelectEventDetails"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbSelectEventDetails"); _glfw.x11.xkb.SetDetectableAutoRepeat = (PFN_XkbSetDetectableAutoRepeat) - _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSetDetectableAutoRepeat"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XkbSetDetectableAutoRepeat"); _glfw.x11.xrm.DestroyDatabase = (PFN_XrmDestroyDatabase) - _glfw_dlsym(_glfw.x11.xlib.handle, "XrmDestroyDatabase"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmDestroyDatabase"); _glfw.x11.xrm.GetResource = (PFN_XrmGetResource) - _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetResource"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmGetResource"); _glfw.x11.xrm.GetStringDatabase = (PFN_XrmGetStringDatabase) - _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetStringDatabase"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmGetStringDatabase"); _glfw.x11.xrm.Initialize = (PFN_XrmInitialize) - _glfw_dlsym(_glfw.x11.xlib.handle, "XrmInitialize"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmInitialize"); _glfw.x11.xrm.UniqueQuark = (PFN_XrmUniqueQuark) - _glfw_dlsym(_glfw.x11.xlib.handle, "XrmUniqueQuark"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XrmUniqueQuark"); _glfw.x11.xlib.UnregisterIMInstantiateCallback = (PFN_XUnregisterIMInstantiateCallback) - _glfw_dlsym(_glfw.x11.xlib.handle, "XUnregisterIMInstantiateCallback"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "XUnregisterIMInstantiateCallback"); _glfw.x11.xlib.utf8LookupString = (PFN_Xutf8LookupString) - _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8LookupString"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "Xutf8LookupString"); _glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties) - _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8SetWMProperties"); + _glfwPlatformGetModuleSymbol(_glfw.x11.xlib.handle, "Xutf8SetWMProperties"); if (_glfw.x11.xlib.utf8LookupString && _glfw.x11.xlib.utf8SetWMProperties) _glfw.x11.xlib.utf8 = GLFW_TRUE; @@ -1427,43 +1427,43 @@ void _glfwPlatformTerminate(void) if (_glfw.x11.x11xcb.handle) { - _glfw_dlclose(_glfw.x11.x11xcb.handle); + _glfwPlatformFreeModule(_glfw.x11.x11xcb.handle); _glfw.x11.x11xcb.handle = NULL; } if (_glfw.x11.xcursor.handle) { - _glfw_dlclose(_glfw.x11.xcursor.handle); + _glfwPlatformFreeModule(_glfw.x11.xcursor.handle); _glfw.x11.xcursor.handle = NULL; } if (_glfw.x11.randr.handle) { - _glfw_dlclose(_glfw.x11.randr.handle); + _glfwPlatformFreeModule(_glfw.x11.randr.handle); _glfw.x11.randr.handle = NULL; } if (_glfw.x11.xinerama.handle) { - _glfw_dlclose(_glfw.x11.xinerama.handle); + _glfwPlatformFreeModule(_glfw.x11.xinerama.handle); _glfw.x11.xinerama.handle = NULL; } if (_glfw.x11.xrender.handle) { - _glfw_dlclose(_glfw.x11.xrender.handle); + _glfwPlatformFreeModule(_glfw.x11.xrender.handle); _glfw.x11.xrender.handle = NULL; } if (_glfw.x11.vidmode.handle) { - _glfw_dlclose(_glfw.x11.vidmode.handle); + _glfwPlatformFreeModule(_glfw.x11.vidmode.handle); _glfw.x11.vidmode.handle = NULL; } if (_glfw.x11.xi.handle) { - _glfw_dlclose(_glfw.x11.xi.handle); + _glfwPlatformFreeModule(_glfw.x11.xi.handle); _glfw.x11.xi.handle = NULL; } @@ -1474,7 +1474,7 @@ void _glfwPlatformTerminate(void) if (_glfw.x11.xlib.handle) { - _glfw_dlclose(_glfw.x11.xlib.handle); + _glfwPlatformFreeModule(_glfw.x11.xlib.handle); _glfw.x11.xlib.handle = NULL; } } diff --git a/src/x11_platform.h b/src/x11_platform.h index 2db58eea..ac8319de 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -384,10 +383,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(Vk #include "null_joystick.h" #endif -#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) -#define _glfw_dlclose(handle) dlclose(handle) -#define _glfw_dlsym(handle, name) dlsym(handle, name) - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11 #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11