From 8ce82a873ac1667ee4cbdc83b812a91e4ada0edf Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 11 Dec 2024 14:30:13 -0500 Subject: Add dylib abstraction to isolate platform-specific code --- src/world.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/world.c') diff --git a/src/world.c b/src/world.c index a614918..c23a34e 100644 --- a/src/world.c +++ b/src/world.c @@ -4,6 +4,11 @@ #include "lilv_config.h" #include "lilv_internal.h" +#ifdef LILV_DYN_MANIFEST +# include "dylib.h" +# include +#endif + #include #include #include @@ -13,10 +18,6 @@ #include #include -#ifdef LILV_DYN_MANIFEST -# include -#endif - #include #include #include @@ -551,8 +552,8 @@ lilv_world_load_dyn_manifest(LilvWorld* world, } // Open library - dlerror(); - void* lib = dlopen(lib_path, RTLD_LAZY); + dylib_error(); + void* lib = dylib_open(lib_path, DYLIB_LAZY); if (!lib) { LILV_ERRORF( "Failed to open dynmanifest library `%s' (%s)\n", lib_path, dlerror()); @@ -564,11 +565,11 @@ lilv_world_load_dyn_manifest(LilvWorld* world, // Open dynamic manifest typedef int (*OpenFunc)(LV2_Dyn_Manifest_Handle*, const LV2_Feature* const*); - OpenFunc dmopen = (OpenFunc)lilv_dlfunc(lib, "lv2_dyn_manifest_open"); + OpenFunc dmopen = (OpenFunc)dylib_func(lib, "lv2_dyn_manifest_open"); if (!dmopen || dmopen(&handle, &dman_features)) { LILV_ERRORF("No `lv2_dyn_manifest_open' in `%s'\n", lib_path); sord_iter_free(binaries); - dlclose(lib); + dylib_close(lib); lilv_free(lib_path); continue; } @@ -576,11 +577,11 @@ lilv_world_load_dyn_manifest(LilvWorld* world, // Get subjects (the data that would be in manifest.ttl) typedef int (*GetSubjectsFunc)(LV2_Dyn_Manifest_Handle, FILE*); GetSubjectsFunc get_subjects_func = - (GetSubjectsFunc)lilv_dlfunc(lib, "lv2_dyn_manifest_get_subjects"); + (GetSubjectsFunc)dylib_func(lib, "lv2_dyn_manifest_get_subjects"); if (!get_subjects_func) { LILV_ERRORF("No `lv2_dyn_manifest_get_subjects' in `%s'\n", lib_path); sord_iter_free(binaries); - dlclose(lib); + dylib_close(lib); lilv_free(lib_path); continue; } @@ -647,12 +648,12 @@ lilv_dynmanifest_free(LilvDynManifest* dynmanifest) { typedef int (*CloseFunc)(LV2_Dyn_Manifest_Handle); CloseFunc close_func = - (CloseFunc)lilv_dlfunc(dynmanifest->lib, "lv2_dyn_manifest_close"); + (CloseFunc)dylib_func(dynmanifest->lib, "lv2_dyn_manifest_close"); if (close_func) { close_func(dynmanifest->handle); } - dlclose(dynmanifest->lib); + dylib_close(dynmanifest->lib); lilv_node_free(dynmanifest->bundle); free(dynmanifest); } -- cgit v1.2.1