From 9d8dad7ea1285e1c3aeb16814fed3b595854946e Mon Sep 17 00:00:00 2001 From: anth64 Date: Wed, 22 Oct 2025 19:20:48 +0200 Subject: [PATCH] platform specific dynamic library loading --- src/platform.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/platform.c diff --git a/src/platform.c b/src/platform.c new file mode 100644 index 0000000..a960f54 --- /dev/null +++ b/src/platform.c @@ -0,0 +1,32 @@ +#ifdef _WIN32 +#include +#else +#include +#endif + +void *platform_load_library(const char *path) +{ +#ifdef _WIN32 + return (void *)LoadLibraryA(path); +#else + return dlopen(path, RTLD_NOW); +#endif +} + +void platform_unload_library(void *handle) +{ +#ifdef _WIN32 + FreeLibrary((HMODULE)handle); +#else + dlclose(handle); +#endif +} + +void *platform_get_symbol(void *handle, const char *symbol) +{ +#ifdef _WIN32 + return (void *)GetProcAddress((HMODULE)handle, symbol); +#else + return dlsym(handle, symbol); +#endif +}