diff options
author | David Robillard <d@drobilla.net> | 2020-09-27 16:16:15 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-09-27 16:16:15 +0200 |
commit | e5345ab3e4bad3ee929c0f08a9161b46fa6e2071 (patch) | |
tree | a2b5d9b32f3643e2a301680a1ef6f750d0993c0a /src/suil_internal.h | |
parent | 0ab07d65fe9261ecfa495090691db324eff7aefc (diff) | |
download | suil-e5345ab3e4bad3ee929c0f08a9161b46fa6e2071.tar.gz suil-e5345ab3e4bad3ee929c0f08a9161b46fa6e2071.tar.bz2 suil-e5345ab3e4bad3ee929c0f08a9161b46fa6e2071.zip |
Add a less janky portability wrapper for dlopen() and friends
Diffstat (limited to 'src/suil_internal.h')
-rw-r--r-- | src/suil_internal.h | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/suil_internal.h b/src/suil_internal.h index a217d60..c55e2ee 100644 --- a/src/suil_internal.h +++ b/src/suil_internal.h @@ -17,22 +17,12 @@ #ifndef SUIL_INTERNAL_H #define SUIL_INTERNAL_H +#include "dylib.h" #include "suil_config.h" #include "lv2/ui/ui.h" #include "suil/suil.h" -#ifdef _WIN32 -#include <windows.h> -#define dlopen(path, flags) LoadLibrary(path) -#define dlclose(lib) FreeLibrary((HMODULE)lib) -#define inline __inline -#define snprintf _snprintf -static inline const char* dlerror(void) { return "Unknown error"; } -#else -#include <dlfcn.h> -#endif - #include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -126,10 +116,10 @@ suil_open_module(const char* module_name) mod_dir, SUIL_DIR_SEP, SUIL_MODULE_PREFIX, module_name, SUIL_MODULE_EXT); - dlerror(); - void* lib = dlopen(path, RTLD_NOW); + dylib_error(); + void* lib = dylib_open(path, DYLIB_NOW); if (!lib) { - SUIL_ERRORF("Failed to open module %s (%s)\n", path, dlerror()); + SUIL_ERRORF("Failed to open module %s (%s)\n", path, dylib_error()); } free(path); |