mirror of
https://github.com/libretro/RetroArch
synced 2025-03-14 01:19:01 +00:00
Add dynamic loading for Win32.
This commit is contained in:
parent
bd23e23661
commit
ed172fd1e4
@ -35,6 +35,10 @@ ifeq ($(HAVE_XML), 1)
|
||||
LIBS += -lxml2
|
||||
endif
|
||||
|
||||
ifeq ($(DYNAMIC), 1)
|
||||
DEFINES += -DHAVE_DYNAMIC
|
||||
endif
|
||||
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
endif
|
||||
|
27
dynamic.c
27
dynamic.c
@ -26,18 +26,29 @@
|
||||
#include <libsnes.hpp>
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#define SYM(x) do { \
|
||||
p##x = ((void*)GetProcAddress(lib_handle, #x)); \
|
||||
if (p##x == NULL) { SSNES_ERR("Failed to load symbol: \"%s\"\n", #x); exit(1); } \
|
||||
} while(0)
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#define SYM(x) do { \
|
||||
p##x = dlsym(lib_handle, #x); \
|
||||
if (p##x == NULL) { SSNES_ERR("Failed to load symbol: \"%s\"\n", #x); exit(1); } \
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
#endif // _WIN32
|
||||
#endif // HAVE_DYNAMIC
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
#ifdef _WIN32
|
||||
static HMODULE lib_handle;
|
||||
#else
|
||||
static void *lib_handle = NULL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void (*psnes_init)(void);
|
||||
|
||||
@ -86,7 +97,11 @@ void (*psnes_term)(void);
|
||||
static void load_dynamic(void)
|
||||
{
|
||||
SSNES_LOG("Loading dynamic libsnes from: \"%s\"\n", g_settings.libsnes);
|
||||
#ifdef _WIN32
|
||||
lib_handle = LoadLibrary(g_settings.libsnes);
|
||||
#else
|
||||
lib_handle = dlopen(g_settings.libsnes, RTLD_LAZY);
|
||||
#endif
|
||||
if (!lib_handle)
|
||||
{
|
||||
SSNES_ERR("Failed to open dynamic library: \"%s\"\n", g_settings.libsnes);
|
||||
@ -171,6 +186,12 @@ void uninit_dlsym(void)
|
||||
{
|
||||
#ifdef HAVE_DYNAMIC
|
||||
if (lib_handle)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
FreeLibrary(lib_handle);
|
||||
#else
|
||||
dlclose(lib_handle);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user