diff --git a/docs/README-migration.md b/docs/README-migration.md index 7c13e0291..27ef83256 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -1104,6 +1104,8 @@ The following symbols have been renamed: ## SDL_loadso.h +Shared object handles are now `SDL_SharedObject *`, an opaque type, instead of `void *`. This is just for type-safety and there is no functional difference. + SDL_LoadFunction() now returns `SDL_FunctionPointer` instead of `void *`, and should be cast to the appropriate function type. You can define SDL_FUNCTION_POINTER_IS_VOID_POINTER in your project to restore the previous behavior. ## SDL_log.h diff --git a/include/SDL3/SDL_loadso.h b/include/SDL3/SDL_loadso.h index ab34a3862..14b0b8086 100644 --- a/include/SDL3/SDL_loadso.h +++ b/include/SDL3/SDL_loadso.h @@ -26,6 +26,14 @@ * * System-dependent library loading routines. * + * Shared objects are code that is programmatically loadable at runtime. + * Windows calls these "DLLs", Linux calls them "shared libraries", etc. + * + * To use them, build such a library, then call SDL_LoadObject() on it. + * Once loaded, you can use SDL_LoadFunction() on that object to find the + * address of its exported symbols. When done with the object, call + * SDL_UnloadObject() to dispose of it. + * * Some things to keep in mind: * * - These functions only work on C function names. Other languages may have @@ -52,6 +60,17 @@ extern "C" { #endif +/** + * An opaque datatype that represents a loaded shared object. + * + * \since This datatype is available since SDL 3.0.0. + * + * \sa SDL_LoadObject + * \sa SDL_LoadFunction + * \sa SDL_UnloadObject + */ +typedef struct SDL_SharedObject SDL_SharedObject; + /** * Dynamically load a shared object. * @@ -59,12 +78,14 @@ extern "C" { * \returns an opaque pointer to the object handle or NULL on failure; call * SDL_GetError() for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \sa SDL_LoadFunction * \sa SDL_UnloadObject */ -extern SDL_DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile); +extern SDL_DECLSPEC SDL_SharedObject * SDLCALL SDL_LoadObject(const char *sofile); /** * Look up the address of the named function in a shared object. @@ -86,22 +107,29 @@ extern SDL_DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile); * \returns a pointer to the function or NULL on failure; call SDL_GetError() * for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \sa SDL_LoadObject */ -extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_LoadFunction(void *handle, const char *name); +extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_LoadFunction(SDL_SharedObject *handle, const char *name); /** * Unload a shared object from memory. * + * Note that any pointers from this object looked up through SDL_LoadFunction() + * will no longer be valid. + * * \param handle a valid shared object handle returned by SDL_LoadObject(). * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \sa SDL_LoadObject */ -extern SDL_DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); +extern SDL_DECLSPEC void SDLCALL SDL_UnloadObject(SDL_SharedObject *handle); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c index 7d6e5cb0c..c53157ee0 100644 --- a/src/audio/aaudio/SDL_aaudio.c +++ b/src/audio/aaudio/SDL_aaudio.c @@ -55,7 +55,7 @@ struct SDL_PrivateAudioData typedef struct AAUDIO_Data { - void *handle; + SDL_SharedObject *handle; #define SDL_PROC(ret, func, params) ret (*func) params; #include "SDL_aaudiofuncs.h" } AAUDIO_Data; diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index cf67a42fc..8b804c4b8 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -91,7 +91,7 @@ static int (*ALSA_snd_pcm_chmap_print)(const snd_pcm_chmap_t *map, size_t maxlen #define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof static const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC; -static void *alsa_handle = NULL; +static SDL_SharedObject *alsa_handle = NULL; static bool load_alsa_sym(const char *fn, void **addr) { diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index 43864b2cd..609e1b37a 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -39,7 +39,7 @@ static bool SupportsIMMDevice = false; #endif // DirectX function pointers for audio -static void *DSoundDLL = NULL; +static SDL_SharedObject *DSoundDLL = NULL; typedef HRESULT(WINAPI *fnDirectSoundCreate8)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN); typedef HRESULT(WINAPI *fnDirectSoundEnumerateW)(LPDSENUMCALLBACKW, LPVOID); typedef HRESULT(WINAPI *fnDirectSoundCaptureCreate8)(LPCGUID, LPDIRECTSOUNDCAPTURE8 *, LPUNKNOWN); diff --git a/src/audio/jack/SDL_jackaudio.c b/src/audio/jack/SDL_jackaudio.c index 958348ed9..b590386e9 100644 --- a/src/audio/jack/SDL_jackaudio.c +++ b/src/audio/jack/SDL_jackaudio.c @@ -51,7 +51,7 @@ static bool load_jack_syms(void); #ifdef SDL_AUDIO_DRIVER_JACK_DYNAMIC static const char *jack_library = SDL_AUDIO_DRIVER_JACK_DYNAMIC; -static void *jack_handle = NULL; +static SDL_SharedObject *jack_handle = NULL; // !!! FIXME: this is copy/pasted in several places now static bool load_jack_sym(const char *fn, void **addr) diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c index 1cfe9a8d1..d803c8d73 100644 --- a/src/audio/pipewire/SDL_pipewire.c +++ b/src/audio/pipewire/SDL_pipewire.c @@ -92,7 +92,7 @@ static int (*PIPEWIRE_pw_properties_setf)(struct pw_properties *, const char *, #ifdef SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC static const char *pipewire_library = SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC; -static void *pipewire_handle = NULL; +static SDL_SharedObject *pipewire_handle = NULL; static bool pipewire_dlsym(const char *fn, void **addr) { diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 733904362..0961bdaed 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -134,7 +134,7 @@ static bool load_pulseaudio_syms(void); #ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC; -static void *pulseaudio_handle = NULL; +static SDL_SharedObject *pulseaudio_handle = NULL; static bool load_pulseaudio_sym(const char *fn, void **addr) { diff --git a/src/audio/sndio/SDL_sndioaudio.c b/src/audio/sndio/SDL_sndioaudio.c index 91cfe79da..0776a4529 100644 --- a/src/audio/sndio/SDL_sndioaudio.c +++ b/src/audio/sndio/SDL_sndioaudio.c @@ -66,7 +66,7 @@ static void (*SNDIO_sio_initpar)(struct sio_par *); #ifdef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC static const char *sndio_library = SDL_AUDIO_DRIVER_SNDIO_DYNAMIC; -static void *sndio_handle = NULL; +static SDL_SharedObject *sndio_handle = NULL; static bool load_sndio_sym(const char *fn, void **addr) { diff --git a/src/camera/pipewire/SDL_camera_pipewire.c b/src/camera/pipewire/SDL_camera_pipewire.c index 2631e640d..edbda2903 100644 --- a/src/camera/pipewire/SDL_camera_pipewire.c +++ b/src/camera/pipewire/SDL_camera_pipewire.c @@ -101,7 +101,7 @@ static int (*PIPEWIRE_pw_properties_setf)(struct pw_properties *, const char *, #ifdef SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC static const char *pipewire_library = SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC; -static void *pipewire_handle = NULL; +static SDL_SharedObject *pipewire_handle = NULL; static bool pipewire_dlsym(const char *fn, void **addr) { diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c index b13d27bfb..371e16e0a 100644 --- a/src/core/linux/SDL_dbus.c +++ b/src/core/linux/SDL_dbus.c @@ -26,7 +26,7 @@ #ifdef SDL_USE_LIBDBUS // we never link directly to libdbus. static const char *dbus_library = "libdbus-1.so.3"; -static void *dbus_handle = NULL; +static SDL_SharedObject *dbus_handle = NULL; static char *inhibit_handle = NULL; static unsigned int screensaver_cookie = 0; static SDL_DBusContext dbus; diff --git a/src/core/linux/SDL_udev.h b/src/core/linux/SDL_udev.h index d501b385e..c165bfecb 100644 --- a/src/core/linux/SDL_udev.h +++ b/src/core/linux/SDL_udev.h @@ -86,7 +86,7 @@ typedef struct SDL_UDEV_Symbols typedef struct SDL_UDEV_PrivateData { const char *udev_library; - void *udev_handle; + SDL_SharedObject *udev_handle; struct udev *udev; struct udev_monitor *udev_mon; int ref_count; diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index cfaec9dad..214ced1bf 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -654,8 +654,8 @@ SDL_DYNAPI_PROC(SDL_Surface*,SDL_LoadBMP,(const char *a),(a),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_LoadBMP_IO,(SDL_IOStream *a, bool b),(a,b),return) SDL_DYNAPI_PROC(void*,SDL_LoadFile,(const char *a, size_t *b),(a,b),return) SDL_DYNAPI_PROC(void*,SDL_LoadFile_IO,(SDL_IOStream *a, size_t *b, bool c),(a,b,c),return) -SDL_DYNAPI_PROC(SDL_FunctionPointer,SDL_LoadFunction,(void *a, const char *b),(a,b),return) -SDL_DYNAPI_PROC(void*,SDL_LoadObject,(const char *a),(a),return) +SDL_DYNAPI_PROC(SDL_FunctionPointer,SDL_LoadFunction,(SDL_SharedObject *a, const char *b),(a,b),return) +SDL_DYNAPI_PROC(SDL_SharedObject*,SDL_LoadObject,(const char *a),(a),return) SDL_DYNAPI_PROC(bool,SDL_LoadWAV,(const char *a, SDL_AudioSpec *b, Uint8 **c, Uint32 *d),(a,b,c,d),return) SDL_DYNAPI_PROC(bool,SDL_LoadWAV_IO,(SDL_IOStream *a, bool b, SDL_AudioSpec *c, Uint8 **d, Uint32 *e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(bool,SDL_LockAudioStream,(SDL_AudioStream *a),(a),return) @@ -973,7 +973,7 @@ SDL_DYNAPI_PROC(bool,SDL_TryWaitSemaphore,(SDL_Semaphore *a),(a),return) SDL_DYNAPI_PROC(char*,SDL_UCS4ToUTF8,(Uint32 a, char *b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_UnbindAudioStream,(SDL_AudioStream *a),(a),) SDL_DYNAPI_PROC(void,SDL_UnbindAudioStreams,(SDL_AudioStream **a, int b),(a,b),) -SDL_DYNAPI_PROC(void,SDL_UnloadObject,(void *a),(a),) +SDL_DYNAPI_PROC(void,SDL_UnloadObject,(SDL_SharedObject *a),(a),) SDL_DYNAPI_PROC(bool,SDL_UnlockAudioStream,(SDL_AudioStream *a),(a),return) SDL_DYNAPI_PROC(void,SDL_UnlockJoysticks,(void),(),) SDL_DYNAPI_PROC(void,SDL_UnlockMutex,(SDL_Mutex *a),(a),) diff --git a/src/gpu/d3d11/SDL_gpu_d3d11.c b/src/gpu/d3d11/SDL_gpu_d3d11.c index 39bbd9e2f..ff3b9370b 100644 --- a/src/gpu/d3d11/SDL_gpu_d3d11.c +++ b/src/gpu/d3d11/SDL_gpu_d3d11.c @@ -737,9 +737,9 @@ struct D3D11Renderer IDXGIInfoQueue *dxgiInfoQueue; #endif - void *d3d11_dll; - void *dxgi_dll; - void *dxgidebug_dll; + SDL_SharedObject *d3d11_dll; + SDL_SharedObject *dxgi_dll; + SDL_SharedObject *dxgidebug_dll; Uint8 debugMode; BOOL supportsTearing; @@ -5886,7 +5886,8 @@ static bool D3D11_SupportsTextureFormat( static bool D3D11_PrepareDriver(SDL_VideoDevice *this) { - void *d3d11_dll, *dxgi_dll; + SDL_SharedObject *d3d11_dll; + SDL_SharedObject *dxgi_dll; PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc; D3D_FEATURE_LEVEL levels[] = { D3D_FEATURE_LEVEL_11_1 }; PFN_CREATE_DXGI_FACTORY1 CreateDxgiFactoryFunc; diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c index cc002160f..31bc04865 100644 --- a/src/gpu/d3d12/SDL_gpu_d3d12.c +++ b/src/gpu/d3d12/SDL_gpu_d3d12.c @@ -576,8 +576,8 @@ struct D3D12Renderer IDXGIInfoQueue *dxgiInfoQueue; #endif IDXGIAdapter1 *adapter; - void *dxgi_dll; - void *dxgidebug_dll; + SDL_SharedObject *dxgi_dll; + SDL_SharedObject *dxgidebug_dll; #endif ID3D12Debug *d3d12Debug; bool supportsTearing; @@ -7762,8 +7762,8 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this) #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) return true; #else - void *d3d12Dll; - void *dxgiDll; + SDL_SharedObject *d3d12Dll; + SDL_SharedObject *dxgiDll; PFN_D3D12_CREATE_DEVICE D3D12CreateDeviceFunc; PFN_CREATE_DXGI_FACTORY1 CreateDXGIFactoryFunc; HRESULT res; diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c index d40e9a928..890bc2347 100644 --- a/src/hidapi/SDL_hidapi.c +++ b/src/hidapi/SDL_hidapi.c @@ -695,7 +695,7 @@ typedef struct DRIVER_hid_device_ DRIVER_hid_device; static struct { - void *libhandle; + SDL_SharedObject *libhandle; /* *INDENT-OFF* */ // clang-format off int (LIBUSB_CALL *init)(libusb_context **ctx); diff --git a/src/joystick/gdk/SDL_gameinputjoystick.c b/src/joystick/gdk/SDL_gameinputjoystick.c index 77ce854f4..8b53f8d60 100644 --- a/src/joystick/gdk/SDL_gameinputjoystick.c +++ b/src/joystick/gdk/SDL_gameinputjoystick.c @@ -60,7 +60,7 @@ typedef struct joystick_hwdata } GAMEINPUT_InternalJoystickHwdata; static GAMEINPUT_InternalList g_GameInputList = { NULL }; -static void *g_hGameInputDLL = NULL; +static SDL_SharedObject *g_hGameInputDLL = NULL; static IGameInput *g_pGameInput = NULL; static GameInputCallbackToken g_GameInputCallbackToken = GAMEINPUT_INVALID_CALLBACK_TOKEN_VALUE; static Uint64 g_GameInputTimestampOffset; diff --git a/src/loadso/dlopen/SDL_sysloadso.c b/src/loadso/dlopen/SDL_sysloadso.c index 66c64b12c..58bf3e0b6 100644 --- a/src/loadso/dlopen/SDL_sysloadso.c +++ b/src/loadso/dlopen/SDL_sysloadso.c @@ -32,7 +32,7 @@ #include "../../video/uikit/SDL_uikitvideo.h" #endif -void *SDL_LoadObject(const char *sofile) +SDL_SharedObject *SDL_LoadObject(const char *sofile) { void *handle; const char *loaderror; @@ -49,10 +49,10 @@ void *SDL_LoadObject(const char *sofile) if (!handle) { SDL_SetError("Failed loading %s: %s", sofile, loaderror); } - return handle; + return (SDL_SharedObject *) handle; } -SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) +SDL_FunctionPointer SDL_LoadFunction(SDL_SharedObject *handle, const char *name) { void *symbol = dlsym(handle, name); if (!symbol) { @@ -72,7 +72,7 @@ SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) return symbol; } -void SDL_UnloadObject(void *handle) +void SDL_UnloadObject(SDL_SharedObject *handle) { if (handle) { dlclose(handle); diff --git a/src/loadso/dummy/SDL_sysloadso.c b/src/loadso/dummy/SDL_sysloadso.c index 34de994b9..9092f2772 100644 --- a/src/loadso/dummy/SDL_sysloadso.c +++ b/src/loadso/dummy/SDL_sysloadso.c @@ -25,21 +25,19 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ // System dependent library loading routines -void *SDL_LoadObject(const char *sofile) +SDL_SharedObject *SDL_LoadObject(const char *sofile) { - const char *loaderror = "SDL_LoadObject() not implemented"; - SDL_SetError("Failed loading %s: %s", sofile, loaderror); + SDL_Unsupported(); return NULL; } -SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) +SDL_FunctionPointer SDL_LoadFunction(SDL_SharedObject *handle, const char *name) { - const char *loaderror = "SDL_LoadFunction() not implemented"; - SDL_SetError("Failed loading %s: %s", name, loaderror); + SDL_Unsupported(); return NULL; } -void SDL_UnloadObject(void *handle) +void SDL_UnloadObject(SDL_SharedObject *handle) { // no-op. } diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c index b069a9c32..67fceb0d0 100644 --- a/src/loadso/windows/SDL_sysloadso.c +++ b/src/loadso/windows/SDL_sysloadso.c @@ -27,7 +27,7 @@ #include "../../core/windows/SDL_windows.h" -void *SDL_LoadObject(const char *sofile) +SDL_SharedObject *SDL_LoadObject(const char *sofile) { if (!sofile) { SDL_InvalidParamError("sofile"); @@ -35,32 +35,30 @@ void *SDL_LoadObject(const char *sofile) } LPWSTR wstr = WIN_UTF8ToStringW(sofile); - void *handle = (void *)LoadLibrary(wstr); + HMODULE handle = LoadLibraryW(wstr); SDL_free(wstr); // Generate an error message if all loads failed if (!handle) { char errbuf[512]; - SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); - SDL_strlcat(errbuf, sofile, SDL_arraysize(errbuf)); + SDL_snprintf(errbuf, sizeof (errbuf), "Failed loading %s", sofile); WIN_SetError(errbuf); } - return handle; + return (SDL_SharedObject *) handle; } -SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) +SDL_FunctionPointer SDL_LoadFunction(SDL_SharedObject *handle, const char *name) { SDL_FunctionPointer symbol = (SDL_FunctionPointer)GetProcAddress((HMODULE)handle, name); if (!symbol) { char errbuf[512]; - SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); - SDL_strlcat(errbuf, name, SDL_arraysize(errbuf)); + SDL_snprintf(errbuf, sizeof (errbuf), "Failed loading %s", name); WIN_SetError(errbuf); } return symbol; } -void SDL_UnloadObject(void *handle) +void SDL_UnloadObject(SDL_SharedObject *handle) { if (handle) { FreeLibrary((HMODULE)handle); diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 2bb829e04..1d9b29134 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -153,8 +153,8 @@ typedef struct // Private renderer data typedef struct { - void *hDXGIMod; - void *hD3D11Mod; + SDL_SharedObject *hDXGIMod; + SDL_SharedObject *hD3D11Mod; IDXGIFactory2 *dxgiFactory; IDXGIAdapter *dxgiAdapter; IDXGIDebug *dxgiDebug; diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index f444505f9..df6e7e417 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -179,8 +179,8 @@ typedef struct // Private renderer data typedef struct { - void *hDXGIMod; - void *hD3D12Mod; + SDL_SharedObject *hDXGIMod; + SDL_SharedObject *hD3D12Mod; #if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) UINT64 frameToken; #else diff --git a/src/storage/steam/SDL_steamstorage.c b/src/storage/steam/SDL_steamstorage.c index 07e5def83..ca0188ee7 100644 --- a/src/storage/steam/SDL_steamstorage.c +++ b/src/storage/steam/SDL_steamstorage.c @@ -32,7 +32,7 @@ typedef struct STEAM_RemoteStorage { - void *libsteam_api; + SDL_SharedObject *libsteam_api; #define STEAM_PROC(ret, func, parms) \ steamfntype_##func func; #include "SDL_steamstorage_proc.h" diff --git a/src/test/SDL_test_memory.c b/src/test/SDL_test_memory.c index 524404dc5..1b7907263 100644 --- a/src/test/SDL_test_memory.c +++ b/src/test/SDL_test_memory.c @@ -34,7 +34,7 @@ static bool s_unwind_symbol_names = true; #include static struct { - HMODULE module; + SDL_SharedObject *module; BOOL (WINAPI *pSymInitialize)(HANDLE hProcess, PCSTR UserSearchPath, BOOL fInvadeProcess); BOOL (WINAPI *pSymFromAddr)(HANDLE hProcess, DWORD64 Address, PDWORD64 Displacement, PSYMBOL_INFO Symbol); BOOL (WINAPI *pSymGetLineFromAddr64)(HANDLE hProcess, DWORD64 qwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line); diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 53886b989..c85c6abc6 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -299,7 +299,8 @@ void SDL_EGL_UnloadLibrary(SDL_VideoDevice *_this) static bool SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_path) { - void *egl_dll_handle = NULL, *opengl_dll_handle = NULL; + SDL_SharedObject *egl_dll_handle = NULL; + SDL_SharedObject *opengl_dll_handle = NULL; const char *path = NULL; #if defined(SDL_VIDEO_DRIVER_WINDOWS) const char *d3dcompiler; diff --git a/src/video/SDL_egl_c.h b/src/video/SDL_egl_c.h index e330471c7..05410f62c 100644 --- a/src/video/SDL_egl_c.h +++ b/src/video/SDL_egl_c.h @@ -64,7 +64,8 @@ typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSy typedef struct SDL_EGL_VideoData { - void *opengl_dll_handle, *egl_dll_handle; + SDL_SharedObject *opengl_dll_handle; + SDL_SharedObject *egl_dll_handle; EGLDisplay egl_display; EGLConfig egl_config; int egl_swapinterval; diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index bc3571f0f..aada061e9 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -437,7 +437,7 @@ struct SDL_VideoDevice int egl_platform; int driver_loaded; char driver_path[256]; - void *dll_handle; + SDL_SharedObject *dll_handle; } gl_config; SDL_EGLAttribArrayCallback egl_platformattrib_callback; @@ -467,7 +467,7 @@ struct SDL_VideoDevice SDL_FunctionPointer vkEnumerateInstanceExtensionProperties; int loader_loaded; char loader_path[256]; - void *loader_handle; + SDL_SharedObject *loader_handle; } vulkan_config; /* * * */ diff --git a/src/video/haiku/SDL_bopengl.cc b/src/video/haiku/SDL_bopengl.cc index e69e08c35..11235982a 100644 --- a/src/video/haiku/SDL_bopengl.cc +++ b/src/video/haiku/SDL_bopengl.cc @@ -56,7 +56,7 @@ bool HAIKU_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) if ( get_image_symbol(info.id, "glBegin", B_SYMBOL_TYPE_ANY, &location) == B_OK) { - _this->gl_config.dll_handle = (void *) (addr_t) info.id; + _this->gl_config.dll_handle = (SDL_SharedObject *) (addr_t) info.id; _this->gl_config.driver_loaded = 1; SDL_strlcpy(_this->gl_config.driver_path, "libGL.so", SDL_arraysize(_this->gl_config.driver_path)); diff --git a/src/video/vivante/SDL_vivantevideo.h b/src/video/vivante/SDL_vivantevideo.h index e4bd0c9e9..b24d85ca0 100644 --- a/src/video/vivante/SDL_vivantevideo.h +++ b/src/video/vivante/SDL_vivantevideo.h @@ -39,7 +39,7 @@ struct SDL_VideoData #ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK vdkPrivate vdk_private; #else - void *egl_handle; // EGL shared library handle + SDL_SharedObject *egl_handle; // EGL shared library handle EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplay)(void *context); EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplayByIndex)(int DisplayIndex); void(EGLAPIENTRY *fbGetDisplayGeometry)(EGLNativeDisplayType Display, int *Width, int *Height); diff --git a/src/video/wayland/SDL_waylanddyn.c b/src/video/wayland/SDL_waylanddyn.c index bee980f06..ea15da397 100644 --- a/src/video/wayland/SDL_waylanddyn.c +++ b/src/video/wayland/SDL_waylanddyn.c @@ -30,7 +30,7 @@ typedef struct { - void *lib; + SDL_SharedObject *lib; const char *libname; } waylanddynlib; diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index e494e4502..74bb8c15c 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -606,7 +606,7 @@ static DWORD IME_GetId(SDL_VideoData *videodata, UINT uIndex) static void IME_SetupAPI(SDL_VideoData *videodata) { char ime_file[MAX_PATH + 1]; - void *hime = 0; + SDL_SharedObject *hime = 0; HKL hkl = 0; videodata->GetReadingString = NULL; videodata->ShowReadingWindow = NULL; diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index 472c5bf29..221db107a 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -393,7 +393,7 @@ static bool WIN_GetMonitorDESC1(HMONITOR hMonitor, DXGI_OUTPUT_DESC1 *desc) { typedef HRESULT (WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc = NULL; - void *hDXGIMod = NULL; + SDL_SharedObject *hDXGIMod = NULL; bool found = false; hDXGIMod = SDL_LoadObject("dxgi.dll"); diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h index 869e8ad36..87eaaaf47 100644 --- a/src/video/windows/SDL_windowsvideo.h +++ b/src/video/windows/SDL_windowsvideo.h @@ -389,7 +389,7 @@ struct SDL_VideoData #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) // Xbox doesn't support user32/shcore // Touch input functions - void *userDLL; + SDL_SharedObject *userDLL; /* *INDENT-OFF* */ // clang-format off BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT ); BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int ); @@ -410,7 +410,7 @@ struct SDL_VideoData LONG (WINAPI *DisplayConfigGetDeviceInfo)( DISPLAYCONFIG_DEVICE_INFO_HEADER*); /* *INDENT-ON* */ // clang-format on - void *shcoreDLL; + SDL_SharedObject *shcoreDLL; /* *INDENT-OFF* */ // clang-format off HRESULT (WINAPI *GetDpiForMonitor)( HMONITOR hmonitor, MONITOR_DPI_TYPE dpiType, @@ -421,7 +421,7 @@ struct SDL_VideoData #endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #ifdef HAVE_DXGI_H - void *dxgiDLL; + SDL_SharedObject *dxgiDLL; IDXGIFactory *pDXGIFactory; #endif @@ -475,7 +475,7 @@ struct SDL_VideoData #ifndef SDL_DISABLE_WINDOWS_IME HKL ime_hkl; - void *ime_himm32; + SDL_SharedObject *ime_himm32; /* *INDENT-OFF* */ // clang-format off UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen); BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow); diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 9d1d820c4..3954dcc78 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -740,7 +740,7 @@ bool WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properties #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) // FIXME: does not work on all hardware configurations with different renders (i.e. hybrid GPUs) if (window->flags & SDL_WINDOW_TRANSPARENT) { - void *handle = SDL_LoadObject("dwmapi.dll"); + SDL_SharedObject *handle = SDL_LoadObject("dwmapi.dll"); if (handle) { DwmEnableBlurBehindWindow_t DwmEnableBlurBehindWindowFunc = (DwmEnableBlurBehindWindow_t)SDL_LoadFunction(handle, "DwmEnableBlurBehindWindow"); if (DwmEnableBlurBehindWindowFunc) { @@ -1199,7 +1199,7 @@ static DWM_WINDOW_CORNER_PREFERENCE WIN_UpdateCornerRoundingForHWND(HWND hwnd, D { DWM_WINDOW_CORNER_PREFERENCE oldPref = DWMWCP_DEFAULT; - void *handle = SDL_LoadObject("dwmapi.dll"); + SDL_SharedObject *handle = SDL_LoadObject("dwmapi.dll"); if (handle) { DwmGetWindowAttribute_t DwmGetWindowAttributeFunc = (DwmGetWindowAttribute_t)SDL_LoadFunction(handle, "DwmGetWindowAttribute"); DwmSetWindowAttribute_t DwmSetWindowAttributeFunc = (DwmSetWindowAttribute_t)SDL_LoadFunction(handle, "DwmSetWindowAttribute"); @@ -1218,7 +1218,7 @@ static COLORREF WIN_UpdateBorderColorForHWND(HWND hwnd, COLORREF colorRef) { COLORREF oldPref = DWMWA_COLOR_DEFAULT; - void *handle = SDL_LoadObject("dwmapi.dll"); + SDL_SharedObject *handle = SDL_LoadObject("dwmapi.dll"); if (handle) { DwmGetWindowAttribute_t DwmGetWindowAttributeFunc = (DwmGetWindowAttribute_t)SDL_LoadFunction(handle, "DwmGetWindowAttribute"); DwmSetWindowAttribute_t DwmSetWindowAttributeFunc = (DwmSetWindowAttribute_t)SDL_LoadFunction(handle, "DwmSetWindowAttribute"); @@ -2223,7 +2223,7 @@ bool WIN_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool foc void WIN_UpdateDarkModeForHWND(HWND hwnd) { - void *handle = SDL_LoadObject("dwmapi.dll"); + SDL_SharedObject *handle = SDL_LoadObject("dwmapi.dll"); if (handle) { DwmSetWindowAttribute_t DwmSetWindowAttributeFunc = (DwmSetWindowAttribute_t)SDL_LoadFunction(handle, "DwmSetWindowAttribute"); if (DwmSetWindowAttributeFunc) { diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c index e2220e526..0c73360d4 100644 --- a/src/video/x11/SDL_x11dyn.c +++ b/src/video/x11/SDL_x11dyn.c @@ -34,7 +34,7 @@ typedef struct { - void *lib; + SDL_SharedObject *lib; const char *libname; } x11dynlib; diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 8230c8d24..7eb6f467e 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -164,7 +164,7 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this); bool X11_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) { Display *display; - void *handle; + SDL_SharedObject *handle; if (_this->gl_data) { return SDL_SetError("OpenGL context already created"); diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index ce92e480c..f97ba902b 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -145,7 +145,7 @@ struct SDL_VideoData #ifdef SDL_VIDEO_VULKAN // Vulkan variables only valid if _this->vulkan_config.loader_handle is not NULL - void *vulkan_xlib_xcb_library; + SDL_SharedObject *vulkan_xlib_xcb_library; PFN_XGetXCBConnection vulkan_XGetXCBConnection; #endif diff --git a/test/testloadso.c b/test/testloadso.c index 2a6f0e532..f1b197081 100644 --- a/test/testloadso.c +++ b/test/testloadso.c @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) int hello = 0; const char *libname = NULL; const char *symname = NULL; - void *lib = NULL; + SDL_SharedObject *lib = NULL; fntype fn = NULL; SDLTest_CommonState *state;